#include <bits/stdc++.h>
using namespace std;
pair <long long, long long> point[400001];
tuple<int, int, int> ques[400000];
pair<int, int> ans[400000];
int otr[400000];
pair <int, int> answer[400000];
int main()
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie();
    cout.tie();
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, q;
    cin >> n >> q;
    point[0] = {0, 0};
    for (int i = 0; i < n; i++)
    {
        long long d, k;
        cin >> d >> k;
        otr[i] = k;
        point[i + 1] = {point[i].first + d, point[i].second + d * k};
    }
    n++;
    for (int i = 0; i < q; i++)
    {
        int u, v;
        cin >> u >> v;
        ques[i] = (make_tuple(u, v, i));
    }
    sort(ques, ques + q);
    int ind = 0;
    for (int i = 0; i < q; i++)
    {
        int L, R;
        if (i != 0 && get<0>(ques[i]) == get<1>(ques[i - 1]))
        {
            L = answer[get<2>(ques[i - 1])].first;
            R = answer[get<2>(ques[i - 1])].second;
        }
        else
        {
            while (ind != n - 1 && point[ind + 1].first < get<0>(ques[i]))
                ind++;
            L = ind;
            R = ind + 1;
        }
        while (L > 0 && otr[L - 1] * (get<0>(ques[i]) - point[L].first) <= get<1>(ques[i]) - point[L].second)
            L--;
        while (R < n - 1 && otr[R] * (point[R + 1].first - get<0>(ques[i])) >= (point[R + 1].second - get<1>(ques[i])))
            R++;
        answer[get<2>(ques[i])] = {point[L].first, point[R].first};
    }
    for (int i = 0; i < q; i++)
        cout << answer[i].first << ' ' << answer[i].second << endl;
}
