//#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

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

typedef long long ll;

struct point {
	ll x, y;
};

struct vec {
	ll x, y;
	vec(point a, point b): x(b.x - a.x), y(b.y - a.y) {}
};

struct query {
	ll x, y;
	int num;
};

bool operator< (query a, query b) {
	return a.x < b.x || (a.x == b.x && a.y < b.y);
}

const int INF = int(1e9);
const int MAXN = int(4e5);
int n, q;
point p[MAXN + 1];
query f[MAXN];
ll ans_l[MAXN], ans_r[MAXN];

ll cross_product(vec a, vec b) {
	return a.x * b.y - a.y * b.x;
}

int main() {
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) {
		ll d, k;
		cin >> d >> k;
		p[i].x = p[i - 1].x + d;
		p[i].y = p[i - 1].y + d * k;
	}
	for (int i = 0; i < q; ++i) {
		f[i].num = i;
		cin >> f[i].x >> f[i].y;
	}
	sort(f, f + q);
	if (f[0].x == f[q - 1].x) {
		point b;
		b.x = f[0].x;
		int m = 0;
		while (p[m].x < b.x)
			++m;
		--m;
		int l = m, r = m + 1;
		for (int i = 0; i < q; ++i) {
			b.y = f[i].y;
			for (int j = l - 1; j >= 0; --j)
				if (cross_product(vec(b, p[j + 1]), vec(b, p[j])) <= 0)
					l = j;
				else
					break;
			for (int j = r + 1; j <= n; ++j)
				if (cross_product(vec(b, p[j - 1]), vec(b, p[j])) >= 0)
					r = j;
				else
					break;
			ans_l[f[i].num] = p[l].x;
			ans_r[f[i].num] = p[r].x;
		}
	} else {
		for (int i = 0; i < q; ++i) {
			point b;
			b.x = f[i].x, b.y = f[i].y;
			ll lx = f[i].x, rx = f[i].y;
			int m = 0;
			while (p[m].x < b.x)
				++m;
			--m;
			for (int j = m; j >= 0; --j)
				if (cross_product(vec(b, p[j + 1]), vec(b, p[j])) <= 0)
					lx = p[j].x;
				else
					break;
			for (int j = m + 1; j <= n; ++j)
				if (cross_product(vec(b, p[j - 1]), vec(b, p[j])) >= 0)
					rx = p[j].x;
				else
					break;
			ans_l[f[i].num] = lx;
			ans_r[f[i].num] = rx;
		}
	}
	for (int i = 0; i < q; ++i)
		cout << ans_l[i] << ' ' << ans_r[i] << endl;
	return 0;
}