#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; ++i)
#define frab(i, a, b) for (int i = a; i < b; ++i)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;

const ll N = 1e5 + 1;

int d[N], k[N];
int x[N], y[N];

bool crossProduct(int l, int xb, int yb) {
    int x0 = x[l], y0 = y[l], x1 = x[l - 1], y1 = y[l - 1];
    int tx1 = x0 - xb, ty1 = y0 - yb, tx2 = x1 - xb, ty2 = y1 - yb;
    return (tx1 * ty2 - tx2 * ty1 <= 0);
}

bool crossProduct2(int r, int xb, int yb) {
    int x0 = x[r + 1], y0 = y[r + 1], x1 = x[r], y1 = y[r];
    int tx1 = x0 - xb, ty1 = y0 - yb, tx2 = x1 - xb, ty2 = y1 - yb;
    return (tx1 * ty2 - tx2 * ty1 <= 0);
}

int main() {
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, q;
    cin >> n >> q;
    fr(i, n)
        cin >> d[i] >> k[i];
    frab(i, 1, n + 1) {
        x[i] = x[i - 1] + d[i - 1];
        y[i] = y[i - 1] + k[i - 1] * d[i - 1];
    }

    //frab(i, 0, n + 1)
      //  cout << x[i] << " " << y[i] << endl;

    fr(i, q) {
        int xb, yb;
        cin >> xb >> yb;
        int l = 0, r = n;
        while (l < n && x[l + 1] <= xb)
            l++;
        while (r && x[r - 1] >= xb)
            r--;
        while (l && crossProduct(l, xb, yb))
            l--;
        while (r < n && crossProduct2(r, xb, yb))
            r++;
        cout << x[l] << " " << x[r] << endl;
    }

}
