#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;
    bool hr = 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 (qv[i] != qv[i + 1])
            hr = false;
    }
    if (hr)
    {
        vector<pair<double, int> > srt;
        for (i = 0; i < q; i++)
        {
            srt.push_back({qu[i], -i - 1});
        }
        ll v = qv[0];
        for (i = 0; i < n; i++)
        {
            if (k[i] != 0)
            {
                double d1 = ((double) v - y[i]) / k[i];
//                cout << d1 + x[i] << ' ' << x[i] << endl;
                srt.push_back({x[i] + d1, i + 1});
            }
            else
            {
                if (y[i] > v)
                {
                    srt.push_back({x[i], i + 1});
                    srt.push_back({x[i] + d[i], i + 1});
                }
            }
        }
        sort(srt.begin(), srt.end());
        vector<int> al(q), ar(q);
        ll l = 0, r = sum;
        for (i = 0; i < srt.size(); i++)
        {
            if (srt[i].second < 0)
            {
                j = -srt[i].second - 1;
                al[j] = l;
            }
            else
            {
                j = srt[i].second - 1;
                if (k[j] >= 0)
                {
                    l = max(l , x[j] + d[j]);
                }
            }
//            cout << l << ' ' << srt[i].second << endl;
        }
        for (i = srt.size() - 1; i >= 0; i--)
        {
            if (srt[i].second < 0)
            {
                j = -srt[i].second - 1;
                ar[j] = r;
            }
            else
            {
                j = srt[i].second - 1;
                if (k[j] <= 0)
                {
                    r = min(r, x[j]);
                }
            }
//            cout << r << ' ' << srt[i].second << endl;
        }
        for (i = 0; i < q; i++)
        {
            cout << al[i] << ' ' << ar[i] << endl;
        }
    }
    return 0;
}
