#include <bits/stdc++.h>
using namespace std;

struct pt {
    long long x, y;
};

long long n, q;
vector <pt> a;

void prepare() {
    cin >> n >> q;
    long long x = 0, y = 0;
    a.push_back({x, y});
    for(long long i = 0; i < n; i++) {
        long long d, k;
        cin >> d >> k;
        y += k * d;
        x += d;
        a.push_back({x, y});
    }
}

bool toRg(pt w, pt b, pt c) {
    b.x -= w.x;
    b.y -= w.y;
    c.x -= w.x;
    c.y -= w.y;
    return b.x * c.y - b.y * c.x >= 0;
}

bool toLf(pt w, pt b, pt c) {
    b.x -= w.x;
    b.y -= w.y;
    c.x -= w.x;
    c.y -= w.y;
    return b.x * c.y - b.y * c.x <= 0;
}

int main() {
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    freopen("mountain.in", "r", stdin); freopen("mountain.out", "w", stdout);

    prepare();

    while(q--) {
        pt w;
        cin >> w.x >> w.y;

        long long l = 0, r = n + 1, m;
        while(l != r - 1) {
            m = (l + r) >> 1;
            if(a[m].x <= w.x) l = m;
            else r = m;
        }

        long long ansR = a.back().x, ansL = 0;

        for(long long it = r; it < n + 1; it++) {
            if(!toRg(w, a[it - 1], a[it])) {
                ansR = max(w.x, a[it - 1].x);
                break;
            }
        }

        for(long long it = l - 1; it >= 0; it--) {
            if(!toLf(w, a[it + 1], a[it])) {
                ansL = min(a[it + 1].x, w.x);
                break;
            }
        }

        cout << ansL << " " << ansR << endl;

    }

    return 0;
}