#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 400005;

struct Point {
    ll x, y;
    Point() {}
    Point(ll _x, ll _y) {
        x = _x, y = _y;
    }
};

ll x[N], y[N];

bool interByx(ll lb1, ll rb1, ll lb2, ll rb2) {
    return max(lb1, lb2) <= min(rb1, rb2);
}

ll cross(Point a, Point b) {
    return a.x * b.y - a.y * b.x;
}

int sign(ll val) {
    if (val == 0) return 0;
    if (val < 0) return -1;
    return 1;
}

bool iseq(Point a, Point b) {
    return (a.x == b.x && a.y == b.y);
}

bool intersect(Point a, Point b, Point c, Point d) {
    if (!interByx(min(a.x, b.x), max(a.x, b.x), min(c.x, d.x), max(c.x, d.x))) return false;
    if (!interByx(min(a.y, b.y), max(a.y, b.y), min(c.y, d.y), max(c.y, d.y))) return false;
    if (iseq(a, c)) return false;
    if (iseq(a, d)) return false;
    if (iseq(b, c)) return false;
    if (iseq(b, d)) return false;
    Point ab = Point(b.x - a.x, b.y - a.y), ac = Point(c.x - a.x, c.y - a.y), ad = Point(d.x - a.x, d.y - a.y);
    int sg = sign(cross(ab, ac)) * sign(cross(ab, ad));
    if (sg >= 0) return false;

    Point ca = Point(c.x - a.x, c.y - a.y), cb = Point(c.x - b.x, c.y - b.y), cd = Point(c.x - d.x, c.y - d.y);
    sg = sign(cross(cd, ca)) * sign(cross(cd, cb));
    if (sg >= 0) return false;
    return true;
}

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

    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        ll d, k;
        cin >> d >> k;
        x[i + 1] = x[i] + d;
        y[i + 1] = y[i] + k * d;
    }
    ++n;
    for (int i = 0; i < q; ++i) {
        ll vx, vy;
        cin >> vx >> vy;
        ll rx = x[n - 1];
        ll lx = x[0];
        for (int j = 1; j < n; ++j) {
            if (x[j] <= vx) continue;
            bool any = false;
            for (int k = j - 1; k > 0; --k) {
                if (intersect(Point(x[j], y[j]), Point(vx, vy), Point(x[k - 1], y[k - 1]), Point(x[k], y[k]))) {
                    any = true;
                    break;
                }
            }
            if (any) {
                rx = j;
                break;
            }
        }
        for (int j = n - 2; j >= 0; --j) {
            if (x[j] >= vx) continue;
            bool any = false;
            for (int k = j + 2; k < n; ++k) {
                if (intersect(Point(x[j], y[j]), Point(vx, vy), Point(x[k - 1], y[k - 1]), Point(x[k], y[k]))) {
                    any = true;
                    break;
                }
            }
            if (any) {
                lx = j;
                break;
            }
        }
        ll lb = x[lx], rb = x[lx + 1];
        while (rb - lb > 1) {
            ll mb = (lb + rb) >> 1;
            ll k = (y[lx + 1] - y[lx]) / (x[lx + 1] - x[lx]);
            ll cy = y[lx] + k * (mb - x[lx]);
            bool ok = true;
            for (int j = 0; j < n - 1; ++j) {
                if (intersect(Point(mb, cy), Point(vx, vy), Point(x[j], y[j]), Point(x[j + 1], y[j + 1]))) ok = false;
            }
            if (ok) rb = mb; 
            else lb = mb;
        }
        lx = rb;
        lb = x[rx - 1], rb = x[rx];
        while (rb - lb > 1) {
            ll mb = (lb + rb) >> 1;
            ll k = (y[rx] - y[rx - 1]) / (x[rx] - x[rx - 1]);
            ll cy = y[rx - 1] + k * (mb - x[rx - 1]);
            bool ok = true;
            for (int j = 0; j < n - 1; ++j) {
                if (intersect(Point(mb, cy), Point(vx, vy), Point(x[j], y[j]), Point(x[j + 1], y[j + 1]))) ok = false;
            }
            if (ok) lb = mb;
            else rb = mb;
        }
        rx = lb;
        cout << lx << ' ' << rx << '\n';
    }
    return 0;
}