#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
const ll inf = (ll)1e18 + 100;

struct pnt {
    ll x, y;
    pnt(int x = 0, int y = 0) : x(x), y(y) {}
    pnt operator + (pnt b) {
        return pnt(x + b.x, y + b.y);
    }
    pnt operator - (pnt b) {
        return pnt(x - b.x, y - b.y);
    }
    ll operator * (pnt b) {
        return x * b.x + y * b.y;
    }
    ll operator % (pnt b) {
        return x * b.y - y * b.x;
    }
    ll len2() {
        return x * x + y * y;
    }
    void read() {
        cin >> x >> y;
    }
};
pnt p0;

bool intersect(pnt a, pnt b, pnt v) {
    pnt v1 = a - p0;
    pnt v2 = b - p0;
    ll A = v1 % v;
    ll B = v2 % v;
    return (A * B < 0);
}

int main() {
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<ll> d(n + 1), k(n + 1);
    vector<pnt> p(n + 1);
    p[0] = pnt(0, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> d[i] >> k[i];
        p[i].x = p[i - 1].x + d[i];
        p[i].y = p[i - 1].y + k[i] * d[i];
    }
    for (int it = 0; it < q; ++it) {
        pnt p0;
        p0.read();
        int l0 = 0;
        for (; l0 <= n; ++l0)
            if (p[l0].x > p0.x)
                break;
        --l0;
        //cerr << it << "       " << l0 << endl;
        int l = l0;
        for (; l >= 0; --l) {
            bool ok = 1;
            for (int i = l; i < l0; ++i) {
                ll A = ((p[i] - p0) % (p[l] - p0));
                ll B = ((p[i + 1] - p0) % (p[l] - p0));
                if (A * B < 0)  ok = 0;
            }
            if (!ok) break;
        }
        ++l;
        int r0 = n;
        for (; r0 >= 0; --r0)
            if (p[r0].x < p0.x)
                break;
        ++r0;
        int r = r0;
        for (; r <= n; ++r) {
            bool ok = 1;
            for (int i = r0; i < r; ++i) {
                ll A = ((p[i] - p0) % (p[r] - p0));
                ll B = ((p[i + 1] - p0) % (p[r] - p0));
                if (A * B < 0) {
                    ok = 0;
                }
            }
            if (!ok) break;
        }
        --r;
        //cerr << "       " << l0 << ' ' << r0 << endl;
        cout << p[l].x << ' ' << p[r].x << '\n';
    }
    return 0;
}
/*
6 1
3 1
2 -1
1 1
1 -1
1 1
2 -1
5 3

5 3
1 1
1 -2
2 0
2 1
1 -1
3 0
3 5
3 3

6 4
1 2
2 -2
1 1
1 -2
4 1
1 -1
1 4
3 4
10 4
7 4

8 4
1 -3
2 0
1 1
2 0
1 -3
1 3
1 2
1 0
2 -2
6 -1
6 4
7 -4
*/




