#include <bits/stdc++.h>

using namespace std;

struct segment
{
    long long x1, x2, k, m;
    segment(long long x1_, long long x2_, long long k_, long long m_):x1(x1_),x2(x2_),k(k_),m(m_){};
    segment(){};
    bool operator<(const segment &a) const
    {
        return this->x1 < a.x1;
    }
};

segment arr[400005];

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    long long cx = 0,cy = 0;
    for(int i=0;i<n;i++)
    {
        long long d, k;
        cin >> d >> k;
        arr[i] = segment(cx, cx+d, k, cy - k*cx);
        cx += d;
        cy += k * d;
    }
    for(int i=0;i<q;i++)
    {
        int x, h;
        cin >> x >> h;
        int cs = upper_bound(arr, arr+n, segment(x,0,0,0)) - arr - 1;
        long long y = (x - arr[cs].x1) * arr[cs].k + h;
        long long lb = 0, rb = cx;
        for(int j=cs-1;j>=0;j--)
        {
            if(arr[j].k * x + arr[j].m > y)
            {
                lb = arr[j].x2;
                break;
            }
        }
        for(int j=cs+1;j<n;j++)
        {
            if(arr[j].k * x + arr[j].m > y)
            {
                rb = arr[j].x1;
                break;
            }
        }
        cout << lb << ' ' << rb << '\n';
    }
    return 0;
}
