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

struct pt {
    long long x, y;
};

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

bool 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 fl = true;
    s.resize(q);
    for(long long i = 0; i < q; i++) {
        cin >> s[i].x >> s[i].y;
        if(i) {
            if(s[i - 1].x != s[i].x) fl = false;
        }
    }
    return fl;
}

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;
}

bool comp(pair<pt, long long> a, pair<pt, long long> b) {
    return a.first.y <= b.first.y;
}

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

    bool fl = prepare();

    if(!fl) {
        for (auto w : s) {

            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;
        }
    } else {
        vector <pair<long long, long long> > ans((int)q);
        vector <pair<pt, long long> > v;
        for(long long i = 0; i < q; i++) {
            v.push_back({{s[i].x, s[i].y}, i});
        }
        sort(v.begin(), v.end(), comp);

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

        for (auto w : v) {

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

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

            for (long long it = l - 1; it >= 0; it--) {
                if(it + 1 >= a.size()) {
                    cout << 12313254;
                    return 0;
                }
                if (!toLf(w.first, a[it + 1], a[it])) {
                    ansL = min(a[it + 1].x, w.first.x);
                    break;
                } else l = it + 1;
            }
            if(w.second >= ans.size()) {
                cout << "NOOOOO";
                return 0;
            }
            ans[w.second] = {ansL, ansR};
        }
        for(auto x : ans) {
            cout << x.first << " " << x.second << endl;
        }
    }

    return 0;
}