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

using namespace std;

typedef long long ll;

struct Point {
    ll x, y;
    bool operator <(const Point &o) const {
        return x < o.x; // || (x == o.x && y < o.y);
    }
};

struct Vector {
    ll x, y;
    Vector(Point A, Point B) : x(B.x - A.x), y(B.y - A.y) {}
    ll cross(const Vector &o) {
        return x * o.y - y * o.x;
    }
};

bool visible(Point A, Point B, Point C) {
    return Vector(A, C).cross(Vector(A, B)) <= 0;
}

int main() {
#ifndef LOCAL
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<Point> v(n + 1, Point{0, 0});
    for (int i = 1; i <= n; i++) {
        ll d, k;
        cin >> d >> k;
        v[i].x = v[i - 1].x + d;
        v[i].y = v[i - 1].y + k * d;
    }
    while (q--) {
        Point T;
        cin >> T.x >> T.y;
        int idx1 = max((int)(lower_bound(v.begin(), v.end(), T) - v.begin() - 1), 0);
        int idx2 = min((int)(upper_bound(v.begin(), v.end(), T) - v.begin()), n);
        while (idx1 > 0 && visible(v[idx1 - 1], v[idx1], T)) {
            idx1--;
        }
        while (idx2 < n && visible(T, v[idx2], v[idx2 + 1])) {
            idx2++;
        }
        cout << v[idx1].x << ' ' << v[idx2].x << endl;
    }
    return 0;
}
