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

int main() {
	freopen("mountain.in", "r", stdin);
	#ifndef DEBUG
	freopen("mountain.out", "w", stdout);
	#endif
	
	int n, q;
	scanf("%d%d", &n, &q);
	
	vector<long long> x;
	vector<long long> y;
	x.push_back(0);
	y.push_back(0);
	
	for (int i = 0; i < n; i++) {
		int d, k;
		scanf("%d%d", &d, &k);
		int xx = x.back() + d;
		int yy = y.back() + d * k;
		x.push_back(xx);
		y.push_back(yy);
	}
	
	for (int i = 0; i < q; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		
		int xright = 0;
		for (int 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;
			}
		}
		int xleft = n;
		for (int 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;
}
