#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

typedef long long ll;

const long long inf = 2000000000;

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    long long n, q;
    long long i, j;
    cin >> n >> q;
    vector<long long> x(n), y(n), k(n), d(n);
    long long x0 = 0, y0 = 0, sum = 0;
    bool fl = true;
    bool vr = true;
    for (i = 0; i < n; i++)
    {
        x[i] = x0;
        y[i] = y0;
        cin >> d[i] >> k[i];
        sum += d[i];
        x0 += d[i];
        y0 += d[i] * k[i];
        if (k[i] != 1 && k[i] != -1)
            fl = false;
    }
    vector<int> qu(q), qv(q);
    for (i = 0; i < q; i++)
        cin >> qu[i] >> qv[i];
    for (i = 0; i < q - 1; i++)
        if (qu[i] != qu[i + 1])
            vr = false;
    if (vr)
    {
        vector<pair<ll, int> > srt;
        for (i = 0; i < q; i++)
        {
            srt.push_back({-qv[i], -i - 1});
        }
        ll u = qu[0];
        for (i = 0; i < n; i++)
        {
            long long dx = u - x[i];
            y0 = dx * k[i] + y[i];
            srt.push_back({-y0, i + 1});
        }
        sort(srt.begin(), srt.end());
        ll l = 0, r = sum;
        vector<int> ansl(q), ansr(q);
        for (i = 0; i < srt.size(); i++)
        {
            if (srt[i].second < 0)
            {
                j = -srt[i].second - 1;
                ansl[j] = l;
                ansr[j] = r;
            }
            else
            {
                j = srt[i].second - 1;
                if (x[j] > u)
                {
                    r = min(r, x[j]);
                }
                else
                {
                    l = max(l, x[j] + d[j]);
                }
            }
        }
        for (i = 0; i < q; i++)
        {
            cout << ansl[i] << ' ' << ansr[i] << endl;
        }
    }
    return 0;
}
