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

using namespace std;
long long vec(pair<long long, long long> a, pair<long long, long long> b) {
    return a.first * b.second - a.second * b.first;
}
int main() {
freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    long long n, q;
    cin >> n >> q;
        pair<long long, long long> a[n + 1];
    a[0].first = a[0].second = 0;
    long long d, k;
    for (long long i = 1; i <= n; i++) {
        cin >> d >> k;
        a[i].first = a[i - 1].first + d;
        a[i].second = a[i - 1].second + d * k;
        //cout << a[i].first << ' ' << a[i].second << endl;
    }
    long long x1, y1;
    for (long long i = 0; i < q; i++) {
        cin >> x1 >> y1;
        pair<long long,long long> ansl;
         pair<long long,long long> ansr;
         pair<long long,long long> hl;
         pair<long long,long long> hr;
        long long l, r;
        l = r = 0;
        for (long long i = 0; i < n; i++) {
            //cout << a[i].first << ' ' << a[i + 1].first << endl;
            if (a[i].first <= x1 && a[i + 1].first >= x1) {
                ansl = a[i];
                ansr = a[i + 1];
                hl = a[i];
                hr = a[i + 1];
                r = i + 1;
                l = i;
                break;
            }
        }
        //cout << ansr.first << ' ' << ansr.second << endl;
        for (long long i = r + 1; i <= n; i++) {
            if (vec(make_pair(x1 - a[i].first, y1 - a[i].second), make_pair(x1 - hr.first, y1 - hr.second)) <= 0) {
                ansr = a[i];
                hr = a[i];
            } else {
                break;
            }
        }
        for (long long i = l - 1; i >= 0; i--) {
            if (vec(make_pair(x1 - a[i].first, y1 - a[i].second), make_pair(x1 - hl.first, y1 - hl.second)) >= 0) {
                ansl = a[i];
                hl = a[i];
            } else {
                break;
            }
        }
        cout << ansl.first << ' ' << ansr.first << endl;
    }
}
