#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> kk(n), dd(n);
	
	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);
		kk[i] = k;
		dd[i] = d;
		int xx = x.back() + d;
		int yy = y.back() + d * k;
		x.push_back(xx);
		y.push_back(yy);
	}
	
	vector<pair<int, int>> qs(q);
	bool st5 = true;
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &qs[i].first, &qs[i].second);
		if (i > 0 && qs[i].first != qs[i - 1].first) {
			st5 = false;
		}
	}
	
	if (n <= 3000 && q <= 3000) {
		for (int i = 0; i < q; i++) {
			int u = qs[i].first, v = qs[i].second;
			
			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;
	}
	
	if (st5) {
		int uu = qs[0].first;
		
		vector<pair<long long, int>> aright;
		int minx = -1;
		for (int i = 0; i < n; i++) {
			if (x[i] > uu) {
				aright.push_back({y[i + 1] - x[i + 1] * kk[i] + uu * kk[i], i + 1});
			} else {
				minx = i + 1;
			}
		}
		sort(aright.begin(), aright.end());
		vector<int> smright(aright.size() + 1);
		smright[aright.size()] = n + 1;
		for (int i = (int) aright.size() - 1; i >= 0; i--) {
			smright[i] = min(smright[i + 1], aright[i].second);
		}
		
		
		vector<pair<long long, int>> aleft;
		int maxx = -1;
		for (int i = n - 1; i >= 0; i--) {
			if (x[i + 1] < uu) {
				aleft.push_back({y[i] - kk[i] * x[i] + kk[i] * uu, i});
			} else {
				maxx = i;
			}
		}
		sort(aleft.begin(), aleft.end());
		vector<int> smleft(aleft.size() + 1);
		smleft[aleft.size()] = -1;
		for (int i = (int) aleft.size() - 1; i >= 0; i--) {
			smleft[i] = max(smleft[i + 1], aleft[i].second);
		}
		
		
		for (int i = 0; i < q; i++) {
			int L = -1;
			int R = aright.size();
			while (R - L > 1) {
				int M = (R + L) / 2;
				if (aright[M].first <= qs[i].second) {
					L = M;
				} else {
					R = M;
				}
			}
			int xright = smright[R] - 1;
			
			L = -1;
			R = aleft.size();
			while (R - L > 1) {
				int M = (R + L) / 2;
				if (aleft[M].first <= qs[i].second) {
					L = M;
				} else {
					R = M;
				}
			}
			int xleft = smleft[R] + 1;
			
			cout << x[xleft] << ' ' << x[xright] << '\n';
		}
		
	}
	
	return 0;
}
