#include <iostream>
#include <stdio.h>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

vector<pair<pair<long long, long long>, pair<long long, long long> > > v;
vector<pair<pair<int, int>, int> > qv;
vector<pair<int, int> > qres;

signed main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    long long n, q, tx = 0, ty = 0;
    cin >> n >> q;
    v.reserve(n);
    int flag = 1;
    for (long long i = 0; i < n; ++i) {
        long long t1, t2;
        cin >> t1 >> t2;
        v[i] = make_pair(make_pair(tx, ty), make_pair(t1, t2));
        tx += t1;
        ty += t1 * t2;
        if (i > 1 && v[i - 1].first.first != v[i].first.first) {
            flag = 0;
        }
    }
    if (flag) {
    //if (true) {
        qv.resize(q);
        qres.resize(q);
        for (int i = 0; i < q; ++i) {
            int t1 , t2;
            cin >> t1 >> t2;
            qv[i] = make_pair(make_pair(t1, t2), i);
        }
        sort(qv.begin(), qv.end());
        long long cen = 0, way, x = qv[0].first.first;
        for (long long j = 0; j < n; ++j) {
            cen = j;
            if (v[j].first.first + v[j].second.first >= x) {
                break;
            }
        }
        //cout << v[cen].first.first << endl;
        for (int i = 0; i < q; ++i) {
            qres[i].first = v[cen].first.first;
            qres[i].second = v[cen].first.first + v[cen].second.first;
        }

        long long maxh = 0, lx = v[cen].first.first, nowqr = 0;
        for (long long j = cen - 1; j >= 0; --j) {
            maxh = v[j].first.second + (x - v[j].first.first) * v[j].second.second;
            while (maxh > qv[nowqr].first.second && nowqr < q) {
                qres[qv[nowqr].second].first = v[j].first.first + v[j].second.first;
                ++nowqr;
            }
        }
        for (int i = nowqr; i < q; ++i) {
            qres[qv[i].second].first = 0;
        }
        nowqr = 0;
        long long maxh2 = 0, rx = v[cen].first.first + v[cen].second.first;
        for (long long j = cen + 1; j < n; ++j) {
            maxh2 = v[j].first.second + (v[j].first.first - x) * (-v[j].second.second);
            while (maxh2 > qv[nowqr].first.second && nowqr < q) {
                qres[qv[nowqr].second].second = v[j].first.first;
                ++nowqr;
            }
        }
        for (int i = nowqr; i < q; ++i) {
            //cout <<  << endl;
            qres[qv[i].second].second = tx;
        }
        for (int i = 0; i < q; ++i) {
            cout << qres[i].first << " " << qres[i].second << endl;
        }
        return 0;
    }
    for (long long i = 0; i < q; ++i) {
        long long x, y;
        cin >> x >> y;
        long long cen = 0, way;
        for (long long j = 0; j < n; ++j) {
            cen = j;
            if (v[j].first.first + v[j].second.first >= x) {
                break;
            }
        }
        long long maxh = y, lx = v[cen].first.first;
        for (long long j = cen - 1; j >= 0; --j) {
            maxh = v[j].first.second + (x - v[j].first.first) * v[j].second.second;
            if (maxh <= y) {
                lx = v[j].first.first;
            }
            else {
                break;
            }
        }
        long long maxh2 = y, rx = v[cen].first.first + v[cen].second.first;
        for (long long j = cen + 1; j < n; ++j) {
            maxh2 = v[j].first.second + (v[j].first.first - x) * (-v[j].second.second);
            if (maxh2 <= y) {
                rx = v[j].first.first + v[j].second.first;
            }
            else {
                break;
            }
        }
        cout << lx << " " << rx << endl;

    }
    return 0;
}
