#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;

const ld EPS = 1e-9;
const int MAXN = 5000;

ifstream cin("mountain.in");
ofstream cout("mountain.out");

ll x[MAXN];
ll y[MAXN];

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		ll d, k;
		cin >> d >> k;
		x[i + 1] = x[i] + d;
		y[i + 1] = y[i] + d * k;
	}
	for (int w = 0; w < q; ++w) {
		ll cx, cy;
		cin >> cx >> cy;
		int L = 0, R = n;
		while (R - L > 1) {
			int m = (L + R) / 2;
			if (x[m] > cx)
				R = m;
			else
				L = m;
		}
		while (R < n && (ld)(cy - y[R]) / (ld)(cx - x[R]) - EPS <= (ld)(cy - y[R + 1]) / (ld)(cx - x[R + 1])) ++R;
		while (L && (ld)(cy - y[L]) / (ld)(cx - x[L]) >= -EPS + (ld)(cy - y[L - 1]) / (ld)(cx - x[L - 1])) --L;
		cout << x[L] << ' ' << x[R] << '\n';
	}
}