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

using namespace std;

const int inf = 2000000000;

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, q;
    int i, j;
    cin >> n >> q;
    vector<int> x(n), y(n), k(n), d(n);
    int x0 = 0, y0 = 0, sum = 0;
    for (i = 0; i < n; i++)
    {
        x[i] = x0;
        y[i] = y0;
        cin >> d[i] >> k[i];
        sum += d[i];
        x0 += d[i];
        y0 += d[i] * k[i];
    }
    for (j = 0; j < q; j++)
    {
         int u, v;
         cin >> u >> v;
         int l = 0, r = sum;
         for (i = 0; i < n; i++)
         {
             int dx = u - x[i];
             y0 = dx * k[i] + y[i];
             if (y0 > v)
             {
                 if (x[i] + d[i] < u)
                 {
                     l = max(l, x[i] + d[i]);
                 }
                 else
                 {
                     r = min(r, x[i]);
                 }
             }
         }
         cout << l << ' ' << r << endl;

    }
    return 0;
}
