#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
const int MAXN = 100001;

long long v[MAXN][2];
long long k[MAXN];

int main(){
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, q;
    cin >> n >> q;
    long long x = 0;
    long long y = 0;
    for (int i = 0; i < n; i++){
        int t1, t2;
        cin >> t1 >> t2;
        v[i + 1][0] = x + t1;
        x += t1;
        v[i + 1][1] = y + (long long)t1 * t2;
        y += (long long)t1 * t2;
        k[i] = t2;
    }
    //for (int i = 0; i < n + 1; i++){
    //    cout << v[i][0] << ' ' << v[i][1] << endl;
    //}
    //cout << endl;
    for (int p = 0; p < q; p++){
        long long x, y;
        cin >> x >> y;
        int lef = 0;
        int righ = n;
        while (righ - lef > 1){
            int mid = (lef + righ) / 2;
            if (v[mid][0] < x){
                lef = mid;
            }
            else{
                righ = mid;
            }
        }
        int rght = 0;
        int lft = 0;
        if (v[righ][0] == x){
            lft = righ;
            rght = righ;
        }
        else{
            lft = lef;
            rght = righ;
        }
        int i = lft;
        while ((i > 0) && (k[i - 1] * (x - v[i][0]) <= (y - v[i][1]))){
            i -= 1;
        }
        cout << v[i][0] << ' ';
        i = rght;
        while ((i < n) && (k[i] * (x - v[i][0]) <= (y - v[i][1]))){
            i += 1;
        }
        cout << v[i][0] << endl;
    }

}
