#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>

using namespace std;

vector<int> x, y;

long long vect(long long a, long long b, int c, int d, int xx, int yy) {
    return (a - xx) * (d - yy) - (c - xx) * (b - yy);
}

int main() {
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    x.push_back(0);
    y.push_back(0);
    for (int i = 0; i < n; i++) {
        int d, k;
        cin >> d >> k;
        x.push_back(x[i] + d);
        y.push_back(y[i] + d * k);
        //cout << x[i + 1] << ' ' << y[i + 1] << '\n';
    }
    for (int i = 0; i < m; i++) {
        long long a, b;
        cin >> a >> b;
        int t = 0;
        while (x[t] < a && t < n) {
            t++;
        }
        int l = max(0, t - 1);
        while (l > 0 && vect(a, b, x[l - 1], y[l - 1], x[l], y[l]) >= 0) {
            l--;
        }
        int r = t;
        while (r < n && vect(x[r + 1], y[r + 1], a, b, x[r], y[r]) >= 0) {
            r++;
        }
        cout << x[l] << ' ' << x[r] << '\n';
    }
}
