#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <set>
#include <map>

using namespace std;

#define int long long
#define point pair <int, int>
#define x first
#define y second

int vecp(point f, point s) {
	int ans = f.x * s.y - f.y * s.x;
	return ans;
}
point get_v(point f, point s) {
	return make_pair(s.first - f.first, s.second - f.second);
}
bool inter2(point f, point s) {
	if (f.second < f.first) swap(f.first, f.second);
	if (s.second < s.first) swap(s.first, s.second);
	int l = max(f.first, s.first);
	int r = min(f.second, s.second);
	return r >= l;
}
bool ras(int f, int s) {
	return min(f, s) < 0 && max(f, s) > 0;
}
bool inter(point a, point aa, point b, point bb) {
	return ras(vecp(get_v(a, aa), get_v(a, b)), vecp(get_v(a, aa), get_v(a, bb))) &&
		ras(vecp(get_v(b, bb), get_v(b, a)), vecp(get_v(b, bb), get_v(b, aa))) &&
		inter2(make_pair(a.first, aa.first), make_pair(b.first, bb.first)) &&
		inter2(make_pair(a.second, aa.second), make_pair(b.second, bb.second));
}
pair <int, int> a[1000000];

signed main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	
	int n, q;
	cin >> n >> q;
	assert(n != 1);
	for (int i = 1; i <= n; ++i) {
		int k, d;
		cin >> d >> k;
		a[i] = make_pair(a[i - 1].first + d, a[i - 1].second + k * d);
	}
	while (q--) {
		pair <int, int> ans = make_pair(0, a[n].first);
		pair <int, int> tt;
		cin >> tt.first >> tt.second;
		for (int i = 0; i <= n; ++i) {
			pair <int, int> cur = a[i];
			if (cur.first < tt.first) continue;
			for (int j = 1; j <= n; ++j) {
				if (inter(tt, cur, a[j], a[j - 1])) {
					ans.second = a[i - 1].first;
					goto ll;
				}
			}
		}
	ll:;
		for (int i = n; i >= 0; --i) {
			pair <int, int> cur = a[i];
			if (cur.first > tt.first) continue;
			for (int j = 1; j <= n; ++j) {
				if (inter(tt, cur, a[j], a[j - 1])) {
					ans.first = a[i + 1].first;
					goto lll;
				}
			}
		}
	lll:;
		cout << ans.first << ' ' << ans.second << endl;
	}
}