#include <iostream>
#include <cstdio>

using namespace std;

pair<int, int> a[1000000];

int crossproduct(int x, int y, int sx, int sy)
{
	return x * sy - y * sx;
}

int main()
{
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	int n, q;
	cin >> n >> q;
	a[0] = {0, 0};
	for (int i = 0; i < n; i++)
	{
		int x, k;
		cin >> x >> k;
		a[i + 1] = {a[i].first + x, a[i].second + x * k};
	}
	while (q--)
	{
		int x, y;
		cin >> x >> y;
		int ansl = -1;
		for (int i = 0; i < n + 1 and a[i].first <= x; i++)
		{
			bool flag = true;
			for (int j = i + 1; j < n + 1 and a[j].first <= x; j++)
			{
				if (crossproduct(a[i].first - a[j].first, a[i].second - a[j].second, a[j].first - x, a[j].second - y) < 0)
				{
					flag = false;
				}
			}
			if (!flag)
			{
				ansl = i;
			}
		}
		int ansr = n + 1;
		for (int i = n; i >= 0 and a[i].first >= x; i--)
		{
			bool flag = true;
			for (int j = i - 1; j >= 0 and a[j].first >= x; j--)
			{
				if (crossproduct(a[i].first - a[j].first, a[i].second - a[j].second, a[j].first - x, a[j].second - y) >= 0)
				{
					flag = false;
				}
			}
			if (!flag)
			{
				ansr = i;
			}
		}
		cout << a[ansl + 1].first << " " << a[ansr - 1].first << endl;
	}
}
				

