#include <iostream>
#include <fstream>

using namespace std;

const int N = 10001;
int64_t n, q, tx, ty;
int64_t x[N], y[N], k[N], d[N];

//struct point{
//    int x, y;
//
//};

int main()
{
    ifstream cin("mountain.in");
    ofstream cout("mountain.out");
    cin >> n >> q;
    if (n >= N)
        return -1;
    for (int i = 1; i <= n; ++i)
    {
        cin >> d[i] >> k[i];
        x[i] = x[i - 1] + d[i];
        y[i] = y[i - 1] + k[i] * d[i];
    }
    while (q--)
    {
        cin >> tx >> ty;
        int li = 0, ri = n;
        for (int i = 1; x[i] < tx; ++i)
            if (k[i] * (tx - x[i]) + y[i] > ty)
                li = i;
        for (int i = n - 1; x[i] > tx; --i)
            if (k[i + 1] * (tx - x[i]) + y[i] > ty)
                ri = i;
        cout << x[li] << ' ' << x[ri] << '\n';
    }
    return 0;
}
