#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;
const long long N = (long long)1e5 + 113;

struct pt {
	long long x, y;
	pt(long long x = 0, long long y = 0) : x(x), y(y) {}
};
struct vec {
	long long x, y;
	vec(long long x = 0, long long y = 0) : x(x), y(y) {}
	vec(pt b, pt e) : x(b.x - e.x), y(b.y - e.y) {}
}; 

long long operator * (vec a, vec b) {
	return a.x * b.x + a.y * b.y;
}
long long operator ^ (vec a, vec b) {
	return a.x * b.y - a.y * b.x;
}
long long n, q;
pt rat[N];
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("outputGood.txt", "w", stdout);
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	
	
	cin >> n >> q;

	for (long long i = 1; i <= n; i++) {
		long long d, k;
		cin >> d >> k;	
		rat[i] = pt(rat[i - 1].x + d, rat[i - 1].y + k * d);
	}

	for (long long i = 1; i <= q; i++) {
		pt v;
		cin >> v.x >> v.y;
		long long l = 0, r = n;
		for (long long j = 1; j <= n; j++) {
			if (rat[j].x >= v.x)
				break;

			if ((vec(rat[j], rat[j - 1]) ^ vec(v, rat[j])) < 0)
				l = j;
		}

		for (long long j = n - 1; j >= 0; j--) {
			if (rat[j].x <= v.x)
				break;

			if ((vec(v, rat[j]) ^ vec(rat[j], rat[j + 1])) < 0)
				r = j;
		}

		cout << rat[l].x << ' ' << rat[r].x << endl;
	}
} 