#include <fstream>

using namespace std;

    ifstream cin("mountain.in");
    ofstream cout("mountain.out");
struct pt
{
    long long x;
    __int128_t y;
    pt() {}
    pt(long long x_, __int128_t y_)
    {
        x = x_;
        y = y_;
    }
    pt(pt &a, pt &b)
    {
        x = b.x - a.x;
        y = b.y - a.y;
    }
};

__int128_t cross(const pt &a, const pt &b)
{
    //cout << "cross " << a.x << ' ' << (long long)a.y << "   " << b.x << ' ' << (long long)b.y << endl;

    return a.x * b.y - a.y * b.x;
}

pt operator+(const pt&a, const pt&b)
{
    return pt(a.x + b.x, a.y + b.y);
}

int main()
{
    int n, q;
    long long cd, ck;
    cin >> n >> q;
    pt a[n + 1], tow[q];
    a[0] = pt(0, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> cd >> ck;
        a[i + 1] = a[i] + pt(cd, (__int128_t)cd * ck);
    }
    for (int i = 0; i < q; i++)
    {
        cin >> cd >> ck;
        tow[i] = pt(cd, ck);
    }
    int last = 0;
    for (int i = 0; i < q; i++)
    {
        last = 0;
        for (int j = 1; j <= n; j++)
        {
            //cout << tow[i].x << ' ' << (long long)tow[i].y << endl;
            //cout << a[j].x << ' ' << (long long)a[j].y << endl;
            if (tow[i].x > a[j].x)
            {
                if (cross(pt(a[j - 1], a[j]), pt(a[j - 1], tow[i])) < 0)
                    last = j;
            }
            else
            {
                if(last != -1)
                {
                    cout << a[last].x << ' ';
                    last = -1;
                }
                if (cross(pt(a[j], a[j - 1]), pt(a[j], tow[i])) > 0) {
                    cout << a[j - 1].x << '\n';
                    break;
                }
            }
        }
    }
    return 0;
}
