#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;

int n, q;

struct Point {
    ll x, y;

    Point() {}
    Point(ll x, ll y) : x(x), y(y) {}
};

struct Line {
    ll a, b, c;
    Line() {}
    Line(Point pt1, Point pt2) {
        a = pt2.y - pt1.y;
        b = pt1.x - pt2.x;
        c = -a * pt1.x - b * pt1.y;
    }
    ll get(Point pt) {
        return a * pt.x + b * pt.y + c;
    }
};

vector< pair<ll, ll> > A, B;

void solve() {
    vector<Point> pts(n + 1);
    pts[0] = Point(0, 0);
    for (int i = 1; i <= n; i++) {
        ll d = A[i - 1].fi;
        ll k = A[i - 1].se;
        pts[i] = Point(pts[i - 1].x + d, pts[i - 1].y + k * d);
    }

    for (int i = 0; i < q; i++) {
        Point cur = Point(B[i].fi, B[i].se);

        int lb = 0, rb = n + 1;
        while (lb + 1 < rb) {
            int mb = (lb + rb) / 2;
            if (cur.x <= pts[mb].x) rb = mb;
            else lb = mb;
        }
        rb = min(rb, n);

        ll ansr = pts[rb].x;
        ll ansl = pts[lb].x;
        while (rb <= n) {
            Line ln = Line(pts[rb], pts[rb - 1]);
            if (ln.get(cur) >= 0) {
                ansr = pts[rb].x;
                rb++;
            } else break;
        }
        while (lb >= 0) {
            Line ln = Line(pts[lb], pts[lb + 1]);
            if (ln.get(cur) <= 0) {
                ansl = pts[lb].x;
                lb--;
            } else break;
        }

        printf("%lld %lld\n", ansl, ansr);
    }
}

void solveonex() {
    vector<Point> pts(n + 1);
    pts[0] = Point(0, 0);
    for (int i = 1; i <= n; i++) {
        ll d = A[i - 1].fi;
        ll k = A[i - 1].se;
        pts[i] = Point(pts[i - 1].x + d, pts[i - 1].y + k * d);
    }

    vector<Point> qu(q);
    for (int i = 0; i < q; i++) {
        qu[i] = {B[i].fi, B[i].se};
    }
    sort(qu.begin(), qu.end(), [](Point pt1, Point pt2) { return pt1.y < pt2.y; });

    int lb = 0, rb = n + 1;
    while (lb + 1 < rb) {
        int mb = (lb + rb) / 2;
        if (qu[0].x <= pts[mb].x) rb = mb;
        else lb = mb;
    }
    rb = min(rb, n);
    ll ansr = pts[rb].x;
    ll ansl = pts[lb].x;

    for (int i = 0; i < q; i++) {
        Point cur = qu[i];

        while (rb <= n) {
            Line ln = Line(pts[rb], pts[rb - 1]);
            if (ln.get(cur) >= 0) {
                ansr = pts[rb].x;
                rb++;
            } else break;
        }
        while (lb >= 0) {
            Line ln = Line(pts[lb], pts[lb + 1]);
            if (ln.get(cur) <= 0) {
                ansl = pts[lb].x;
                lb--;
            } else break;
        }

        printf("%lld %lld\n", ansl, ansr);
    }
}

int main() {
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);

    while (scanf("%d%d", &n, &q) == 2) {
        A.resize(n);
        for (int i = 0; i < n; i++) {
            scanf("%lld%lld", &A[i].fi, &A[i].se);
        }
        B.resize(q);
        for (int i = 0; i < q; i++) {
            scanf("%lld%lld", &B[i].fi, &B[i].se);
        }

        bool onex = true;
        for (int i = 1; i < q; i++) {
            if (B[i].fi != B[0].fi) {
                onex = false;
                break;
            }
        }
        if (onex) {
            solveonex();
        } else {
            solve();
        }
    }
}
