#include <algorithm>
#include <vector>
#include <fstream>
#include <tuple>
#include <iostream>

using namespace std;

typedef double daburu;

int main()
{
	ifstream cin("mountain.in");
	ofstream cout("mountain.out");
	int n, q; cin >> n >> q;
	++n;
	vector<int> d(n - 1), k(n - 1);
	for (int i = 0; i < n - 1; ++i)
		cin >> d[i] >> k[i];
	vector<int> xs(n), ys(n);
	for (int i = 1; i < n; ++i)
		xs[i] = xs[i - 1] + d[i - 1], ys[i] = ys[i - 1] + d[i - 1] * k[i - 1];
	vector<tuple<int, int, int>> qs(q);
	for (int i = 0; i < q; ++i)
		cin >> get<0>(qs[i]) >> get<1>(qs[i]), get<2>(qs[i]) = i;
	sort(qs.begin(), qs.end());
	vector<pair<int, int>> ans(q, { -1, -1 });
	for (int i = 0; i < q; ++i)
	{
		int qx = get<0>(qs[i]), qy = get<1>(qs[i]);
		int start1 = lower_bound(xs.begin(), xs.end(), qx) - xs.begin();
		int start2 = xs[start1] == qx ? start1 : start1 - 1;
		for (int j = start2; j >= 1; --j)
		{
			//daburu k1 = (ys[j] - qy) / (xs[j] - qx);
			//int k2 = k[j - 1];
			//if (k1 > k2)
			if ((ys[j] - qy) > 1LL * (-k[j - 1]) * abs(xs[j] - qx))
			{
				ans[get<2>(qs[i])].first = xs[j];
				break;
			}
		}
		if (ans[get<2>(qs[i])].first == -1)
			ans[get<2>(qs[i])].first = xs[0];
		for (int j = start1; j < n - 1; ++j)
		{
			//daburu k1 = (ys[j] - qy) / (xs[j] - qx);
			//int k2 = k[j];
			//if (k1 > k[j])
			if ((ys[j] - qy) > 1LL * k[j] * abs(xs[j] - qx))
			{
				ans[get<2>(qs[i])].second = xs[j];
				break;
			}
		}
		if (ans[get<2>(qs[i])].second == -1)
			ans[get<2>(qs[i])].second = xs[n - 1];
	}
	for (auto& x : ans)
		cout << x.first << ' ' << x.second << endl;
}