#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-10;

struct point{
    double x, y;
    point() {};
    point(double x, double y): x(x), y(y) {}
};

struct line {
    double a, b, c;
    line() {};
    line(point p0, point p1) {
        a = p1.y - p0.y;
        b = p0.x - p1.x;
        c = -1 * (p0.x * a + p0.y * b);
    }
};

int n, q;
point p[400001];

bool lgood(int finish, int id, point tow) {
    line a = line(p[id], tow);

    for (int i = id + 1; i <= finish; i++) {
        double y1 = (p[i].x * a.a + a.c) / a.b;
        y1 *= -1.0;
        if (y1 < p[i].y) return false;
    }
    return true;
}

bool rgood(int start, int id, point tow) {
    line a = line(p[id], tow);

    for (int i = start; i < id; i++) {
        double y1 = (p[i].x * a.a + a.c) / a.b;
        y1 *= -1.0;
        if (y1 < p[i].y) return false;
    }
    return true;
}

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

    cin >> n >> q;
    p[0] = point(0.0, 0.0);
    for (int i = 1; i <= n; i++) {
        double d, k;
        cin >> d >> k;
        p[i] = point(p[i - 1].x + d, p[i - 1].y + k * d);
    }

    for (int i = 0; i < q; i++) {
        double x, y;
        cin >> x >> y;
        int right = 0, left = 0;

        while (x > p[right].x && right <= n) right++;
        left = right - 1;

        int l = left;
        int r = right;

        while (lgood(left, l, point(x, y)) && l >= 0) l--;
        while (rgood(right, r, point(x, y)) && r <= n) r++;
        l++;
        r--;
        cout << p[l].x << " " << p[r].x << endl;
     }
     return 0;
}
