#include <bits/stdc++.h>

using namespace std;

long long x[3001], y[3001], k[3001];

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    x[0] = 0;
    y[0] = 0;
    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 qwe = 0; qwe < q; qwe++)
    {
        long long u, v;
        cin >> u >> v;
        int t = n;
        for (int i = 0; i < n; i++)
        {
            if (x[i] <= u && x[i + 1] >= u)
            {
                t = i;
                break;
            }
        }
        long long l = x[t];
        int o = t + 1;
        while (t > 0)
        {
            t--;
            if (y[t] + (u - x[t]) * k[t] > v)
                break;
            else
                l = x[t];
        }
        long long r = x[o];
        t = o;
        while (t < n)
        {
            if (y[t] + k[t] * (u - x[t]) > v)
                break;
            else
            {
                t++;
                r = x[t];
            }
        }
        cout << l << " " << r << endl;
    }
    return 0;
}
