#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for(int i = 0; i < n; i++)
#define sz(a) int(a.size())
#define re return
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll big = 1000000000000000LL;
ll n, q, k, d, x, y;
vector<pll> a;

ll vec(pll a, pll b) {
    re a.fi * b.se - a.se * b.fi;
}
int main() {
    iostream::sync_with_stdio(0), cin.tie(0);
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    cin >> n >> q;
    a.push_back(mp(0, 0));
    forn (i, n) {
        cin >> d >> k;
        a.push_back(mp(a[i].fi + d, a[i].se + d * k));
    }
    forn (i, q) {
        cin >> x >> y;
        int j = lower_bound(a.begin(), a.end(), mp(x, big)) - a.begin(), j2 = j;
        if (a[j].fi < x) j2++;
        while (j > 0 && vec(mp(a[j].fi - x, a[j].se - y), mp(a[j - 1].fi - x, a[j - 1].se - y)) <= 0) {
            j--;
        }
        cout << a[j].fi << " ";
        j = j2;
        while (j + 1 < sz(a) && vec(mp(a[j].fi - x, a[j].se - y), mp(a[j + 1].fi - x, a[j + 1].se - y)) >= 0) {
            j++;
        }
        cout << a[j].fi << "\n";
    }
    re 0;
}

