#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

long long n, q;
long long d[1013], k[1013];
long long x, y;
long long xx[1013];
long long yy[1013];
int main() {
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	//freopen("1.txt", "r", stdin);
	
	cin >> n >> q;
	xx[0] = 0;
	yy[0] = 0;
	for (long long i = 0; i < n; i++) {
		cin >> d[i] >> k[i];
		xx[i + 1] = xx[i] + d[i];
		yy[i + 1] = yy[i] + d[i] * k[i];
	}

	for (long long i = 0; i < q; i++) {
		cin >> x >> y;
		long long l = 0, r = n;
		while (xx[l] < x) {
			l++;
		}
		l--;
		while (xx[r] > x) {
			r--;
		}
		r++;
		while (l != 0 && k[l - 1] * x + (yy[l - 1] - k[l - 1] *  xx[l - 1]) <= y) {
			l--;
		}
		while (r != n && k[r] * x  + (yy[r] - k[r] * xx[r])  <= y) {
			r++;
		}

		cout << xx[l] << " " << xx[r] << endl;
	}
	return 0;
}