#include <bits/stdc++.h>

using namespace std;

long long x[100001], y[100001], k[100001];
pair<long long, int> mas[100001];
pair<long long, long long> ans[100001];

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];
    }
    if ((long long)n * q <= (long long)1e7)
    {
        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;
        }
    }
    else
    {
        long long u;
        for (int i = 0; i < q; i++)
        {
            cin >> u >> mas[i].first;
            mas[i].second = i;
        }
        sort(mas, mas + q);
        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];
        long long r = x[t + 1];
        int o = t + 1;
        for (int i = 0; i < q; i++)
        {
            long long v = mas[i].first;
            while (t > 0)
            {
                t--;
                if (y[t] + (u - x[t]) * k[t] > v)
                {
                    t++;
                    break;
                }
                else
                    l = x[t];
            }
            while (o < n)
            {
                if (y[o] + k[o] * (u - x[o]) > v)
                    break;
                else
                {
                    o++;
                    r = x[o];
                }
            }
            ans[mas[i].second] = {l, r};
        }
        for (int i = 0; i < q; i++)
        {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
    return 0;
}
