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


using namespace std;

int sgn(long long int v) {
    return v < 0 ? -1 : (v > 0 ? +1 : 0);
}

struct vec2 {
    long long int x, y;
    int idx;

    vec2() : x(0), y(0), idx(0) {}
    vec2(long long int _x, long long int _y) : x(_x), y(_y), idx(0) {}
    vec2(long long int _x, long long int _y, int _idx) : x(_x), y(_y), idx(_idx) {}

    void operator+=(const vec2 &v) {
        x += v.x;
        y += v.y;
    }

    void operator-=(const vec2 &v) {
        x -= v.x;
        y -= v.y;
    }

    vec2 operator+(const vec2 &v) const {
        vec2 ret = *this;
        ret += v;
        return ret;
    }

    vec2 operator-(const vec2 &v) const {
        vec2 ret = *this;
        ret -= v;
        return ret;
    }

    long long int dot(const vec2 &v) const {
        return x * v.x + y * v.y;
    }

    long long int crs(const vec2 &v) const {
        return x * v.y - y * v.x;
    }

    int sdot(const vec2 &v) const {
        return sgn(dot(v));
    }

    int scrs(const vec2 &v) const {
        return sgn(crs(v));
    }
};

int main() {
#ifndef LOCAL
    assert(freopen("mountain.in", "r", stdin));
    assert(freopen("mountain.out", "w", stdout));
#endif // LOCAL
    int n, q;
    cin >> n >> q;
    vector<vec2> pts(1);
    long long int d, k;
    for (int i = 0; i < n; ++i) {
        cin >> d >> k;
        vec2 np = pts.back() + vec2(d, d * k);
        pts.push_back(np);
    }
    vector<vec2> ws(q);
    bool same_x = true, same_y = true;
    for (int i = 0; i < q; ++i) {
        cin >> ws[i].x >> ws[i].y;
        ws[i].idx = i;
    }
    for (int i = 1; i < n; ++i) {
        same_x = same_x & (ws[i - 1].x == ws[i].x);
        same_y = same_y & (ws[i - 1].y == ws[i].y);
    }
    if (0 && same_x) {
        sort(ws.begin(), ws.end(), [](const vec2 &a, const vec2 &b) {
            return a.y < b.y;
        });
        int gr = min(n - 1, (int) distance(pts.begin(), upper_bound(pts.begin(), pts.end(), ws[0], [](const vec2 &a, const vec2 &b) {
            return a.x < b.x;
        })));
        int gl = max(0, (int) distance(pts.begin(), lower_bound(pts.begin(), pts.end(), ws[0], [](const vec2 &a, const vec2 &b) {
            return a.x < b.x;
        })) - 1);
        vector<long long int> ans1(q), ans2(q);
        for (int i = 0; i < q; ++i) {
            vec2 w = ws[i];
            for (; gr + 1 < (int) pts.size(); ++gr) {
                if ((pts[gr] - w).scrs(pts[gr + 1] - w) < 0) {
                    break;
                }
            }
            for (; gl - 1 >= 0; --gl) {
                if ((pts[gl] - w).scrs(pts[gl - 1] - w) > 0) {
                    break;
                }
            }
            ans1[w.idx] = pts[gl].x;
            ans2[w.idx] = pts[gr].x;
        }
        for (int i = 0; i < q; ++i) {
            cout << ans1[i] << ' ' << ans2[i] << '\n';
        }
    } else {
        for (int i = 0; i < q; ++i) {
            vec2 w = ws[i];
            int gr = min(n - 1, (int) distance(pts.begin(), upper_bound(pts.begin(), pts.end(), w, [](const vec2 &a, const vec2 &b) {
                return a.x < b.x;
            })));
            for (; gr + 1 < (int) pts.size(); ++gr) {
                if ((pts[gr] - w).scrs(pts[gr + 1] - w) < 0) {
                    break;
                }
            }
            int gl = max(0, (int) distance(pts.begin(), lower_bound(pts.begin(), pts.end(), w, [](const vec2 &a, const vec2 &b) {
                return a.x < b.x;
            })) - 1);
            for (; gl - 1 >= 0; --gl) {
                if ((pts[gl] - w).scrs(pts[gl - 1] - w) > 0) {
                    break;
                }
            }
            cout << pts[gl].x << ' ' << pts[gr].x << '\n';
        }
    }
    cout << flush;

    return 0;
}
