#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;
typedef __int128_t int_type;
using namespace std;

struct point
{
    int_type x, y;
    point() {}
};

struct vect
{
    int_type x, y;
    vect(point a, point b)
    {
        x = b.x - a.x;
        y = b.y - a.y;
    }
};

int_type cp(vect u, vect v)
{
    return u.x * v.y - v.x * u.y;
}

struct query
{
    point p;
    int i;
    query() {};
};

bool operator<(const query& q, const query& p)
{
    if (q.p.x != p.p.x)
        return q.p.x < p.p.x;
    return q.p.y < p.p.y;
}

int main()
{
#ifndef LOCAL
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
#endif
    int n, q;
    cin >> n >> q;
    point a;
    a.x = 0, a.y = 0;
    vector<point> pts(n + 1);
    pts[0] = a;
    for (int i = 0; i < n; i++)
    {
        int k, d;
        cin >> d >> k;
        a.x += (int_type)d;
        a.y += (int_type)k * (int_type)d;
        pts[i + 1] = a;
//        cout << "!" << (int)pts[i + 1].x << " " << (int)pts[i + 1].y << endl;
    }
    if (n <= 3000)
    {
        for (int _ = 0; _ < q; _++)
        {
            int x, y;
            cin >> x >> y;
            point p; p.x = x; p.y = y;
            int _i = 0;
            while (pts[_i].x < p.x) _i++;
            int i = _i;
            if (pts[i].x != p.x)
                i--;
            while (i > 0 && cp(vect(p, pts[i]), vect(p, pts[i - 1])) <= 0)
                i--;
            int j = _i;
            while (j < n && cp(vect(p, pts[j]), vect(p, pts[j + 1])) >= 0)
                j++;
            cout << (int)pts[i].x << " " << (int)pts[j].x << endl;
        }
    }
    else
    {
        int_type* lans = new int_type[q];
        int_type* rans = new int_type[q];
        query* qs = new query[q];
        for (int i = 0; i < q; i++)
        {
            ll x, y;
            cin >> x >> y;
            qs[i].p.x = x;
            qs[i].p.y = y;
            qs[i].i = i;
        }
        sort(qs, qs + q);

        int i = 0;
        while (pts[i].x < qs[0].p.x) i++;
        if (pts[i].x != qs[0].p.x)
            i--;
        while (i > 0 && cp(vect(qs[0].p, pts[i]), vect(qs[0].p, pts[i - 1])) <= 0)
            i--;
        lans[qs[0].i] = pts[i].x;
        for (int j = 0; j < q; j++)
        {
            while (i > 0 && cp(vect(qs[j].p, pts[i]), vect(qs[j].p, pts[i - 1])) <= 0)
                i--;
            lans[qs[j].i] = pts[i].x;
        }

        int j = 0;
        while (pts[j].x < qs[0].p.x) j++;
        while (j < n && cp(vect(qs[0].p, pts[j]), vect(qs[0].p, pts[j + 1])) >= 0)
            j++;
        rans[qs[0].i] = pts[j].x;
        for (i = 1; i < q; i++)
        {
            while (j < n && cp(vect(qs[i].p, pts[j]), vect(qs[i].p, pts[j + 1])) >= 0)
                j++;
            rans[qs[i].i] = pts[j].x;   
        }

        for (i = 0; i < q; i++)
            cout << (int)lans[i] << " " << (int)rans[i] << endl;
    }
    return 0;
}
