#define first f
#define second s
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#define pb push_back
#define all(a) begin(a), end(a)

using namespace std;

const int N = 1000001;
int64_t n, q, tx, ty;
int64_t x[N], y[N], k[N], d[N];
vector<pair<pair<int64_t, int64_t>, int64_t>> v;
pair<int64_t, int64_t> ans[N];
set<int64_t> sx, sy;

//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];
    }
    if (n <= 3e3)
    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';
    }
    else
    {
        while (q--)
            cin >> tx >> ty, v.pb({{tx, ty}, q}), sx.insert(tx), sy.insert(ty);
        if (sx.size() == 1)
        {
            sort(all(v), [](pair<pair<int64_t, int64_t>, int64_t> a, pair<pair<int64_t, int64_t>, int64_t> b){return a.f.s < b.f.s;});
            int li = n, ri = 0;
            for (auto i: v)
            {
                tx = i.f.f, ty = i.f.s;
                while (x[li] >= tx) --li;
                while (x[ri] <= tx) ++ri;
                while (li != 0 && k[li] * (tx - x[li]) + y[li] <= ty) --li;
                while (ri != n && k[ri + 1] * (tx - x[ri]) + y[ri] <= ty) ++ri;
                ans[i.s] = {x[li], x[ri]};
            }
            sort(all(v), [](pair<pair<int64_t, int64_t>, int64_t> a, pair<pair<int64_t, int64_t>, int64_t> b){return a.s > b.s;});
            for (auto i: v)
                cout << ans[i.s].f << ' ' << ans[i.s].s << '\n';
        }
        else if (sy.size() == 1)
        {
            sort(all(v), [](pair<pair<int64_t, int64_t>, int64_t> a, pair<pair<int64_t, int64_t>, int64_t> b){return a.f.f < b.f.f;});
            int li = n, ri = 0;
            for (auto i: v)
            {
                tx = i.f.f, ty = i.f.s;
                while (x[ri] <= tx) ++ri;
                while (ri != n && k[ri + 1] * (tx - x[ri]) + y[ri] <= ty) ++ri;
                ans[i.s].s = x[ri];
            }
            reverse(all(v));
            for (auto i: v)
            {
                tx = i.f.f, ty = i.f.s;
                while (x[li] >= tx) --li;
                while (li != 0 && k[li] * (tx - x[li]) + y[li] <= ty) --li;
                ans[i.s].f = x[li];
            }
            sort(all(v), [](pair<pair<int64_t, int64_t>, int64_t> a, pair<pair<int64_t, int64_t>, int64_t> b){return a.s > b.s;});
            for (auto i: v)
                cout << ans[i.s].f << ' ' << ans[i.s].s << '\n';
        }
    }
    return 0;
}
