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

using namespace std;

typedef long long ll;

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

ll cross(point p1, point p2) {
	return p1.x * p2.y - p1.y * p2.x;
}

point operator -(point p1, point p2) {
	return point(p1.x - p2.x, p1.y - p2.y);
}

const int LEN = 4e5 + 10;

point a[LEN];

int main() {
	freopen("mountain.in", "rt", stdin);
	freopen("mountain.out", "wt", stdout);
	point p;
	int n, q;
	scanf("%d%d", &n, &q);

	ll d, k;

	a[0] = point(0, 0);

	for (int i = 1; i <= n; ++i) {
		scanf("%lld%lld", &d, &k);
		a[i] = point(a[i - 1].x + d, a[i - 1].y + k * d);
	}
	
	++n;

	for (int k = 0; k < q; ++k) {
		scanf("%lld%lld", &p.x, &p.y);
		bool bl, bp;
		for (int i1 = 0; i1 < n; ++i1) {
			bl = 0;
			bp = 0;
			if ((i1 == n - 1) || ((a[i1].x <= p.x) && (a[i1 + 1].x > p.x))) {
				for (int i = i1; i > 0; --i) {
					if (cross(a[i] - p, a[i - 1] - a[i]) > 0) {
						bl = 1;
						printf("%lld ", a[i].x);
						break;
					}
				}
				if (!bl) printf("0 ");
				for (int i = i1 + 1; i < n - 1; ++i) {
					if (cross(a[i] - p, a[i + 1] - a[i]) < 0) {
						bp = 1;
						printf("%lld\n", a[i].x);
						break;
					}
				}
				if (!bp) printf("%lld\n", a[n - 1].x);
				break;
			}

		}

	}

	return 0;
}