#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#pragma comment(linker, "/stack:268435456")

#define ll long long
#define ld long double
#define sz(x) (int) x.size()
#define mp make_pair

const int INF = 1e9;
const ll LINF = 1e18;
const ld EPS = 1e-12;

#define TASKNAME "mountain"

using namespace std;

const int N = 10000;

struct point {
	ll x, y;

	point() : x(0), y(0) {}
	point(ll x, ll y) : x(x), y(y) {}
};

int n, q;

ld calc_k(point a, point b, int t) {
	if (a.x == b.x) {
		return t ? -1e20 : 1e20;
	}

	return ((ld)(a.y - b.y)) / (a.x - b.x);
}

int main() {
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#else
	freopen(TASKNAME ".in", "r", stdin);
	freopen(TASKNAME ".out", "w", stdout);
#endif

	cin >> n >> q;

	vector<point> w;
	w.push_back(point(0, 0));

	for (int i = 0; i < n; i++) {
		ll lx = w[i].x;
		ll ly = w[i].y;
		ll d, k;
		cin >> d >> k;
		w.push_back(point(lx + d, ly + k * d));
	}

	n++;

	if (n <= 5000) {
		for (int i = 0; i < q; i++) {
			point p;
			cin >> p.x >> p.y;

			{
				int left = 0;
				while (left + 1 < n && w[left + 1].x <= p.x) left++;
				int best = left;
				ld max_k = calc_k(p, w[left], 0);
				for (int i = left - 1; i >= 0; i--) {
					ld cur_k = calc_k(p, w[i], 0);
					max_k = min(max_k, cur_k);
					if (cur_k - EPS <= max_k) {
						best = i;
					}
					else {
						break;
					}
				}

				cout << w[best].x << " ";
			}

			{
				int right = n - 1;
				while (right - 1 >= 0 && w[right - 1].x >= p.x) {
					right--;
				}
				int best = right;
				ld max_k = calc_k(p, w[right], 1);
				for (int i = right + 1; i < n; i++) {
					ld cur_k = calc_k(p, w[i], 1);
					max_k = max(max_k, cur_k);
					if (cur_k + EPS >= max_k) {
						best = i;
					}
					else {
						break;
					}
				}

				cout << w[best].x << "\n";
			}
		}
	}
	else {
		vector<pair<ll, ll>> h(q);
		vector<ll> al(q, INF), ar(q, -INF);
		int qx;

		for (int i = 0; i < q; i++) {
			cin >> qx >> h[i].first;
			h[i].second = i;
		}
		
		sort(h.begin(), h.end());

		{
			int left = 0;
			while (left + 1 < n && w[left + 1].x <= qx) left++;
			int ptr = 0;
			ld min_k = calc_k(point(qx, h[ptr].first), w[left], 0);
			int min_ind = left;
			for (int i = left - 1; i >= 0; i--) {
				ld cur_k = calc_k(point(qx, h[ptr].first), w[i], 0);
				if (cur_k < min_k) {
					min_k = cur_k;
					min_ind = i;
				}

				while (ptr < q && cur_k - EPS > min_k) {
					al[h[ptr].second] = w[i + 1].x;
					ptr++;
					if (ptr < q) {
						cur_k = calc_k(point(qx, h[ptr].first), w[i], 0);
						min_k = calc_k(point(qx, h[ptr].first), w[min_ind], 0);
					}
				}
			}

			while (ptr < q) {
				al[h[ptr].second] = w[0].x;
				ptr++;
			}
		}

		{
			int right = n - 1;
			while (right - 1 >= 0 && w[right - 1].x >= qx) right--;
			int ptr = 0;
			ld max_k = calc_k(point(qx, h[ptr].first), w[right], 1);
			int max_ind = right;
			for (int i = right + 1; i < n; i++) {
				ld cur_k = calc_k(point(qx, h[ptr].first), w[i], 1);
				if (cur_k > max_k) {
					max_k = cur_k;
					max_ind = i;
				}

				while (ptr < q && cur_k + EPS < max_k) {
					ar[h[ptr].second] = w[i - 1].x;
					ptr++;
					if (ptr < q) {
						cur_k = calc_k(point(qx, h[ptr].first), w[i], 1);
						max_k = calc_k(point(qx, h[ptr].first), w[max_ind], 1);
					}
				}
			}

			while (ptr < q) {
				ar[h[ptr].second] = w[n - 1].x;
				ptr++;
			}
		}

		for (int i = 0; i < q; i++) {
			cout << al[i] << " " << ar[i] << "\n";
		}
	}

#ifdef _DEBUG
	while (1);
#endif
	return 0;
}