#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxn = 4e5 + 5;

int n, q;
int x[maxn];
int y[maxn];

int angle(int j, int k, int u, int v) {
    int x1 = x[j] - u;
    int y1 = y[j] - v;
    int x2 = x[k] - x[j];
    int y2 = y[k] - y[j];
    return x1 * y2 - x2 * y1;
}

void f(int u, int v) {
    for (int i = n; i > 0; i--) {
        if (x[i] < u && angle(i, i - 1, u, v) > 0) {
            cout << x[i] << ' ';
            return;
        }
    }
    cout << x[0] << ' ';
}

void g(int u, int v) {
    for (int i = 0; i < n; i++) {
        if (x[i] > u && angle(i, i + 1, u, v) < 0) {
            cout << x[i] << '\n';
            return;
        }
    }
    cout << x[n] << '\n';
}

int p1 = -1;
int f2(int u, int v) {
    if (p1 == -1) p1 = n;
    for (; p1 > 0; p1--) {
        if (x[p1] < u && angle(p1, p1 - 1, u, v) > 0) {
            return x[p1];
        }
    }
    return x[0];
}

int p2 = -1;
int g2(int u, int v) {
    if (p2 == -1) p2 = 0;
    for (; p2 < n; p2++) {
        if (x[p2] > u && angle(p2, p2 + 1, u, v) < 0) {
            return x[p2];
        }
    }
    return x[n];
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);

    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        int d, k;
        cin >> d >> k;
        x[i] = x[i - 1] + d;
        y[i] = y[i - 1] + k * d;
    }

    if (n > 3000) {
        vector< pair< pair<int, int>, int> > a(q);
        for (int i = 0; i < q; i++) {
            int u, v;
            cin >> u >> v;
            a[i] = {{v, u}, i};
        }
        sort(a.begin(), a.end());
        vector<int> ansl(q), ansr(q);
        for (int i = 0; i < q; i++) {
            int u, v, ind;
            u = a[i].first.second;
            v = a[i].first.first;
            ind = a[i].second;
            ansl[ind] = f2(u, v);
            ansr[ind] = g2(u, v);
        }
        for (int i = 0; i < q; i++) {
            cout << ansl[i] << ' ' << ansr[i] << '\n';
        }
        return 0;
    }

    for (int i = 0; i < q; i++) {
        int u, v;
        cin >> u >> v;
        f(u, v);
        g(u, v);
    }
}

