#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
#define INF INT_MAX
#define NAME "mountain"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);

using namespace std;

const int N = 100001;

struct t {
    ll d, k;
    pll l, r;
    ll zn;
} a[N];

int n, q, i, j;
ll x, y, ansl, ansr, yy, b, rig;
pll tk;
bool w;

int main()
{
    FREOPEN
    ios_base::sync_with_stdio(0);
    cin >> n >> q;
    for (i = 0; i < n; i++)
        cin >> a[i].d >> a[i].k;
    for (i = 0; i < q; i++) {
        cin >> x >> y;
        rig = 0;
        ansl = 0; ansr = INF;
        tk = mp(0, 0);
        w = 0;
        for (j = 0; tk.fi < x; j++) {
            if (w)
                ansl = tk.fi;
            w = 0;
            b = tk.se - a[j].k * tk.fi;
            yy = a[j].k * x + b;
            if (yy > y)
                w = 1;
            tk = mp(tk.fi + a[j].d, tk.se + a[j].k * a[j].d);
            rig = tk.fi;
        }
        for ( ; j < n; j++) {
            b = tk.se - a[j].k * tk.fi;
            yy = a[j].k * x + b;
            if (yy > y && ansr == INF)
                ansr = tk.fi;
            tk = mp(tk.fi + a[j].d, tk.se + a[j].k * a[j].d);
            rig = tk.fi;
        }
        if (ansr == INF)
            ansr = rig;
        cout << ansl << ' ' << ansr << endl;
    }
    return 0;
}








