#define	_CRT_SECURE_NO_WARNINGS
#define	_USE_MATH_DEFINES
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>

#define	mp	make_pair

using namespace std;

typedef	long long int	ll;
typedef	long double		ld;
typedef	pair<int, int>	ii;
typedef	vector<int>		vi;
typedef	vector<ii>		vii;

const int MAXN = 200000;
const int INF = 1000000010;

int N, Q;
ll D[MAXN], K[MAXN];
ll X[MAXN], Y[MAXN];
ll U[MAXN], V[MAXN];
set<pair<ll, int>> s;
pair<ll, ll> ans[MAXN];

int main() {
#ifdef FILE_IO
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
#endif // FILE_IO

	scanf("%d %d", &N, &Q);
	X[0] = Y[0] = 0;

	for (int i = 0; i < N; i++) {
		scanf("%lld %lld", &D[i], &K[i]);
		X[i + 1] = X[i] + D[i];
		Y[i + 1] = Y[i] + D[i] * K[i];
	}

	bool flag = true;
	for (int i = 0; i < Q; i++) {
		scanf("%lld %lld", &U[i], &V[i]);
		if (i && U[i] != U[i - 1])
			flag = false;
	}

	if (N <= 3000 && Q <= 3000) {
		ll ui, vi;
		int ptrr, ptrl;
		for (int i = 0; i < Q; i++) {
			ui = U[i], vi = V[i];

			ptrl = ptrr = lower_bound(X, X + N + 1, ui) - X;
			if (X[ptrl] > ui)
				ptrl--;

			while (ptrr < N) {
				if (Y[ptrr] - vi > K[ptrr] * (X[ptrr] - ui))
					break;
				ptrr++;
			}

			while (ptrl > 0) {
				if (K[ptrl - 1] * (ui - X[ptrl]) > vi - Y[ptrl])
					break;
				ptrl--;
			}

			printf("%lld %lld\n", X[ptrl], X[ptrr]);
		}

		return 0;
	}

	assert(flag);

	ll ui = U[0];
	int ptrl, ptrr;
	ptrl = ptrr = lower_bound(X, X + N + 1, ui) - X;
	if (X[ptrl] > ui)
		ptrl--;

	for (int i = 0; i < Q; i++)
		s.insert(mp(V[i], i));

	while (ptrr < N) {
		while (!s.empty() && Y[ptrr] - s.begin()->first > K[ptrr] * (X[ptrr] - ui)) {
			ans[s.begin()->second].second = X[ptrr];
			s.erase(s.begin());
		}
		ptrr++;
	}

	while (!s.empty()) {
		ans[s.begin()->second].second = X[N];
		s.erase(s.begin());
	}

	for (int i = 0; i < Q; i++)
		s.insert(mp(V[i], i));

	while (ptrl > 0) {
		while (!s.empty() && K[ptrl - 1] * (ui - X[ptrl]) > s.begin()->first - Y[ptrl]) {
			ans[s.begin()->second].first = X[ptrl];
			s.erase(s.begin());
		}
		ptrl--;
	}

	while (!s.empty()) {
		ans[s.begin()->second].first = X[0];
		s.erase(s.begin());
	}

	for (int i = 0; i < Q; i++)
		printf("%lld %lld\n", ans[i].first, ans[i].second);
	

	return 0;
}
