#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];

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);
	assert(N <= 3000 && Q <= 3000);
	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];
	}

	ll ui, vi;
	int ptrr, ptrl;
	for (int i = 0; i < Q; i++) {
		scanf("%lld %lld", &ui, &vi);
		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;
}