#include <bits/stdc++.h>
using namespace std;

int main() {
	freopen("mountain.in", "r", stdin);
	#ifndef DEBUG
	freopen("mountain.out", "w", stdout);
	#endif
	
	long long n, q;
	scanf("%d%d", &n, &q);
	
	vector<long long> x;
	vector<long long> y;
	x.push_back(0);
	y.push_back(0);
	
	for (long long i = 0; i < n; i++) {
		long long d, k;
		scanf("%d%d", &d, &k);
		long long xx = x.back() + d;
		long long yy = y.back() + d * k;
		x.push_back(xx);
		y.push_back(yy);
	}
	
	for (long long i = 0; i < q; i++) {
		long long u, v;
		scanf("%d%d", &u, &v);
		
		long long xright = 0;
		for (long long i = 0; i < n; i++) {
			if (x[i] <= u) {
				xright = i + 1;
				continue;
			}
			if ((y[i] - y[i + 1]) * (x[i + 1] - u) + y[i + 1] * (x[i + 1] - x[i]) <= v * (x[i + 1] - x[i])) {
				xright = i + 1;
			} else {
				break;
			}
		}
		long long xleft = n;
		for (long long i = n - 1; i >= 0; i--) {
			if (x[i + 1] >= u) {
				xleft = i;
				continue;
			}
			if ((y[i + 1] - y[i]) * (u - x[i]) + y[i] * (x[i + 1] - x[i]) <= v * (x[i + 1] - x[i])) {
				xleft = i;
			} else {
				break;
			}
		}
		
		cout << x[xleft] << ' ' << x[xright] << '\n';
	}
	
	
	return 0;
}
