#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ciso646>
#include <cmath>
#include <cassert>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <initializer_list>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

time_t _timer;
void _pre()
{
	_timer = clock();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifdef ANDREIKKAA
	assert(freopen("input.txt", "r", stdin) != nullptr);
#else
	assert(freopen("fisher.in", "r", stdin) != nullptr);
	assert(freopen("fisher.out", "w", stdout) != nullptr);
#endif
}

void _post()
{
#ifdef ANDREIKKAA
	cout << "\n\n\nTime: " << (clock() - _timer) / (ld)CLOCKS_PER_SEC << endl;
	while (228);
#endif
}

struct Point
{
	int x, y;
};

Point operator+(const Point &a, const Point &b)
{
	return{ a.x + b.x, a.y + b.y };
}

Point operator-(const Point &a, const Point &b)
{
	return{ a.x - b.x, a.y - b.y };
}

void _solve()
{
	const int MAX_N = 3228;
	int n, q;
	cin >> n >> q;
	
	static Point v[MAX_N];
	static int d[MAX_N];
	static int k[MAX_N];
	for (int i = 1; i <= n; ++i)
	{
		cin >> d[i] >> k[i];
		Point vec{d[i], d[i] * k[i]};
		v[i] = v[i - 1] + vec;
	}
	assert(v[n].y == 0);

	for (int i = 0; i < q; ++i)
	{
		int x, y;
		cin >> x >> y;

		int xl = v[0].x, xr = v[n].x;
		for (int j = 1; j <= n and v[j].x < x; ++j)
		{
			int dx = x - v[j - 1].x;
			if (v[j - 1].y + dx * k[j] > y)
			{
				xl = v[j].x;
			}
		}
		for (int j = n - 1; j >= 0 and x < v[j].x; --j)
		{
			int dx = v[j + 1].x - x;
			if (v[j + 1].y - dx * k[j + 1] > y)
			{
				xr = v[j].x;
			}
		}

		cout << xl << " " << xr << endl;
	}
}

int main()
{
	_pre();
	_solve();
	_post();
}