#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;
const long long N = (long long)1e5 + 113;

struct pt {
	long long x, y, ind;
	pt(long long x = 0, long long y = 0, long long ind = 0) : x(x), y(y), ind(ind) {}
};
struct vec {
	long long x, y;
	vec(long long x = 0, long long y = 0) : x(x), y(y) {}
	vec(pt b, pt e) : x(b.x - e.x), y(b.y - e.y) {}
}; 

long long operator * (vec a, vec b) {
	return a.x * b.x + a.y * b.y;
}
long long operator ^ (vec a, vec b) {
	return a.x * b.y - a.y * b.x;
}
bool operator <(pt a, pt b) {
	return a.x < b.x || (a.x == b.x && a.y < b.y);
}
long long n, q;
pt rat[N];
vector <pt> history;
pair <long long, long long> ans[N];
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("outputGood.txt", "w", stdout);
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	
	
	cin >> n >> q;
	for (long long i = 1; i <= n; i++) {
		long long d, k;
		cin >> d >> k;
		rat[i] = pt(rat[i - 1].x + d, rat[i - 1].y + k * d);
	}

	if (n * q <= 9000000) {
		for (long long i = 1; i <= q; i++) {
			pt v;
			cin >> v.x >> v.y;
			long long l = 0, r = n;
			for (long long j = 1; j <= n; j++) {
				if (rat[j].x >= v.x)
					break;

				if ((vec(rat[j], rat[j - 1]) ^ vec(v, rat[j])) < 0)
					l = j;
			}

			for (long long j = n - 1; j >= 0; j--) {
				if (rat[j].x <= v.x)
					break;

				if ((vec(v, rat[j]) ^ vec(rat[j], rat[j + 1])) < 0)
					r = j;
			}

			cout << rat[l].x << ' ' << rat[r].x << endl;
		}
		return 0;
	}

	for (long long i = 1; i <= q; i++) {
		pt v;
		v.ind = i;
		cin >> v.x >> v.y;
		history.push_back(v);
	}
	sort(history.begin(), history.end());

	long long l = 0;
	long long r = n;
	pt v = history[0];
	for (long long j = 1; j <= n; j++) {
		if (rat[j].x >= v.x)
			break;

		if ((vec(rat[j], rat[j - 1]) ^ vec(v, rat[j])) < 0)
			l = j;
	}

	for (long long j = n - 1; j >= 0; j--) {
		if (rat[j].x <= v.x)
			break;

		if ((vec(v, rat[j]) ^ vec(rat[j], rat[j + 1])) < 0)
			r = j;
	}
	ans[v.ind] = make_pair(l, r);

	if (history[0].x == history[q - 1].x) {
		
		for (long long i = 1; i < q; i++) {
			v = history[i];

			while (l > 0 && (vec(rat[l], rat[l - 1]) ^ vec(v, rat[l])) >= 0) {
				l--;
			}
			while (r < n && (vec(v, rat[r]) ^ vec(rat[r], rat[r + 1])) >= 0) {
				r++;
			}
			ans[v.ind] = make_pair(l, r);
		}
		for (long long i = 1; i <= q; i++)
			cout << rat[ans[i].first].x << ' ' << rat[ans[i].second].x << endl;
		return 0;
	}

	for (long long i = 1; i < q; i++) {
		v = history[i];
		while (rat[l].x <= v.x && !((vec(rat[l], rat[l - 1]) ^ vec(v, rat[l])) >= 0)) {
			l++;
		}
		l--;
		while (r < n && (vec(v, rat[r]) ^ vec(rat[r], rat[r + 1])) >= 0) {
			r++;
		}
		ans[v.ind] = make_pair(l, r);
	}
	for (long long i = 1; i <= q; i++)
		cout << rat[ans[i].first].x << ' ' << rat[ans[i].second].x << endl;

} 