#include <iostream>
#include <vector>

using namespace std;
using point = pair<long long, long long>;

point make_vect(point a, point b) {
    return {b.first - a.first, b.second - a.second};
}

long long vect(point a, point b) {
    return {a.first * b.second - a.second * b.first};
}

int main()
{
    freopen("mountain.in", "rt", stdin);
    freopen("mountain.out", "wt", stdout);
    int n, q;
    cin >> n >> q;
    vector<point> points(n + 1);
    points[0] = {0, 0};
    for (int i = 0; i < n; i++) {
        int d, k;
        cin >> d >> k;
        points[i + 1] = {points[i].first + d, points[i].second + d * k};
    }
    for (int z = 0; z < q; z++) {
        int x, y;
        cin >> x >> y;
        long long l, r;
        vector<point> st;
        for (int i = 0; i < n + 1 && points[i].first <= x; i++) {
            while (!st.empty()) {
                point v1 = make_vect(st.back(), {x, y});
                point v2 = make_vect(st.back(), points[i]);
                if (vect(v1, v2) <= 0) break;
                st.pop_back();
            }
            st.push_back(points[i]);
        }
        l = st[0].first;
        if (x > points.back().first) {
            r = st.back().first;
        }
        else {
            st.clear();
            for (int i = n; i >= 0 && points[i].first >= x; i--) {
                while (!st.empty()) {
                    point v1 = make_vect(st.back(), {x, y});
                    point v2 = make_vect(st.back(), points[i]);
                    if (vect(v1, v2) >= 0) break;
                    st.pop_back();
                }
                st.push_back(points[i]);
            }
            r = st[0].first;
        }
        cout << l << " " << r << endl;
    }
    return 0;
}
