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

using namespace std;

typedef long long nagai;
typedef double daburu;

nagai n, q;
vector<pair<nagai, nagai>> ans;
vector<tuple<nagai, nagai, nagai>> qs;
vector<nagai> xs;
vector<nagai> ys;
vector<nagai> d;
vector<nagai> k;

void solve_vert()
{
	sort(qs.begin(), qs.end());
	for (int i = 0; i < q; ++i)
	{
		nagai 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)
		{
			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)
		{
			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;
}

void solve_horiz()
{
	sort(qs.begin(), qs.end());
	int last = 10000000;
	for (int i = q - 1; i >= 0; --i)
	{
		nagai 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 = min(start2, last); j >= 1; --j)
		{
			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];
		last = ans[get<2>(qs[i])].first;
	}
	last = -100;
	for (int i = 0; i < q; ++i)
	{
		nagai qx = get<0>(qs[i]), qy = get<1>(qs[i]);
		int start1 = lower_bound(xs.begin(), xs.end(), qx) - xs.begin();
		for (int j = max(start1, last); j < n - 1; ++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];
		last = ans[get<2>(qs[i])].second;
	}
	for (auto& x : ans)
		cout << x.first << ' ' << x.second << endl;
}

int main()
{
	ifstream cin("mountain.in");
	ofstream cout("mountain.out");
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	nagai n, q; cin >> n >> q;
	++n;
	d.resize(n - 1);
	k.resize(n - 1);
	xs.resize(n);
	ys.resize(n);
	ans = vector<pair<nagai, nagai>>(q, { -1, -1 });
	qs.resize(q);
	for (int i = 0; i < n - 1; ++i)
		cin >> d[i] >> k[i];
	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<nagai, nagai, nagai>> qs(q);
	for (nagai i = 0; i < q; ++i)
		cin >> get<0>(qs[i]) >> get<1>(qs[i]), get<2>(qs[i]) = i;
	bool horiz = true;
	bool vert = true;
	for (int i = 0; i < n - 1; ++i)
	{
		if (get<0>(qs[i]) != get<0>(qs[i + 1]))
			vert = false;
		if (get<1>(qs[i]) != get<1>(qs[i + 1]))
			horiz = false;
	}
	if (false && vert)
	{
		solve_vert();
		return 0;
	}
	if (horiz)
	{
		solve_horiz();
		return 0;
	}
	for (int i = 0; i < q; ++i)
	{
		nagai 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);
			//nagai 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)
		{
			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;
}