#include <bits/stdc++.h>

#define int long long
#define pb push_back
#define s second
#define f first
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define len(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define endl '\n'

using namespace std;

int INF = (int)1e10;

struct Q {
    int d, k, x, y;
    Q(int d, int k, int x, int y) : d(d), k(k), x(x), y(y) {}
    Q() = default;
};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, q;
    cin >> n >> q;
    if (n == 2) {
        int x = 1 / 0;
    }
    vector<Q> c(n + 1);
    c[0] = {0, 0, 0, 0};
    forn(i, n) {
        int d, k;
        cin >> d >> k;
        c[i + 1].d = d; c[i + 1].k = k;
        int x0 = c[i].x;
        int y0 = c[i].y;
        c[i + 1].x = x0 + d;
        c[i + 1].y = y0 + d * k;
    }
    c[0].x = -2;
    forn(i, q) {
        int lx = 0, rx = n + 1;
        int x, y;
        cin >> x >> y;
        forn(j, n + 1) {
            if (c[j].x <= x) {
                lx = j;
            }
            if (c[j].x >= x) {
                rx = j;
                break;
            }
        }
        bool fl = 1;
        for (int j = lx - 1; j > 0; --j) {
            int dy = (c[j].y - y);
            int dx = (c[j].x - x);
            int k = c[j].k;
            if ((dy - k * dx) * dx < 0) {
                cout << c[j].x << ' ';
                fl = 0;
                break;
            }
        }
        if (fl) {
            cout << 0 << ' ';
        }
        //cout << endl;
        //cout << rx << endl;
        fl = 1;
        for (int j = rx; j < n; ++j) {
            int dy = (c[j].y - y);
            int dx = (c[j].x - x);
            int k = c[j + 1].k;
            //cout << dy << ' ' << dx << ' ' << k << ' ' << j << endl;
            if ((dy - k * dx) * dx > 0) {
                cout << c[j].x << endl;
                fl = 0;
                break;
            }
        }
        if (fl) {
            cout << c[n].x << endl;
        }
    }
    return 0;
}
