#include <bits/stdc++.h>

using namespace std;

long long n, q;
long long x[101], y[101], k[101];

int main() {
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        long long d;
        cin >> d >> k[i];
        x[i + 1] = x[i] + d;
        y[i + 1] = y[i] + d * k[i];
    }
    for (int i = 0; i < q; i++) {
        long long u, v;
        cin >> u >> v;
        int ind1 = 0;
        for (int j = 0; j <= n; j++) {
            if (x[j] <= u) {
                ind1++;
            }
        }
        for (int j = ind1; j >= 0; j--) {
            if (v - y[j] < k[j] * (u - x[j])) {
                break;
            }
            ind1 = j;
        }
        int ind2 = n;
        for (int j = n; j >= 0; j--) {
            if (x[j] >= u) {
                ind2 = j;
            }
        }
        if (ind2 == 0) {
            ind2 = 1;
        }
        for (int j = ind2; j <= n; j++) {
            if (v - y[j] < k[j - 1] * (u - x[j])) {
                break;
            }
            ind2 = j;
        }
        cout << x[ind1] << " " << x[ind2] << "\n";
    }
}

