#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cassert>

using namespace std;

typedef long long ll;
typedef long double ld;

vector <pair <ll, ll> > v;
vector <pair <ll, ll> > p;

ll operator *(pair <ll, ll> a, pair <ll, ll> b) { return a.first * b.second - a.second * b.first; }

bool check(ll a, ll b) { return (a > 0 && b > 0) || (a < 0 && b < 0); }

int main() {
    assert(freopen("mountain.in", "r", stdin));
    assert(freopen("mountain.out", "w", stdout));
    //freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(false);

    int n, q; cin >> n >> q;
    ll lx = 0, ly = 0;
    p.push_back({0, 0});
    for (int i = 0; i < n; i++) {
        ll d, k; cin >> d >> k;
        lx += d, ly += d * k;
        v.push_back({1, k});
        p.push_back({lx, ly});
    }

    for (int t = 0; t < q; t++) {
        ll x, y; cin >> x >> y;
        int b = 0;
        for (int i = 0; i < int(p.size()); i++)
            if (p[i].first <= x && x <= p[i + 1].first)
                b = i;
        ll ans1 = 2e9;
        for (int i = b; i > 0; i--) {
            pair <ll, ll> w = make_pair(x - p[i].first, y - p[i].second);
            if (check(v[i] * w, make_pair(-v[i - 1].first, -v[i - 1].second) * w) && ans1 == 2e9)
                ans1 = p[i].first;
        }
        if (ans1 == 2e9)
            ans1 = 0;

        ll ans2 = -1;
        for (int i = b + 1; i < int(v.size()); i++) {
            pair <ll, ll> w = make_pair(x - p[i].first, y - p[i].second);
            if (check(v[i] * w, make_pair(-v[i - 1].first, -v[i - 1].second) * w) && ans2 == -1)
                ans2 = p[i].first;
        }
        if (ans2 == -1)
            ans2 = p.back().first;

        cout << ans1 << " " << ans2 << endl;
    }

    return 0;
}
