#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <string>

using namespace std;

#pragma warning(disable:4996)

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long ll;

pair<ll, ll> p[400400];
ll k[400400];
int n, q;

void solveNQ() {
	for (int i = 0; i < q; ++i) {
		ll u, v;
		scanf("%lld%lld", &u, &v);
		int lx = 0, rx = p[n].x;
		for (int j = 1; j < n; ++j) {
			if (p[j].x >= u) break;
			if (v - p[j].y < k[j - 1] * (u - p[j].x)) {
				lx = p[j].x;
			}
		}
		for (int j = n - 1; j > 0; --j) {
			if (p[j].x <= u) break;
			if (p[j].y - v > k[j] * (p[j].x - u)) {
				rx = p[j].x;
			}
		}
		printf("%d %d\n", lx, rx);
	}
}

void solve1() {
	vector<pair<ll, ll> > V;
	for (int i = 0; i < n; ++i) {
		if (k[i] == -1) {
			V.push_back(p[i]);
		}
	}
	V.push_back(p[n]);
	for (int i = 0; i < q; ++i) {
		int l = 0, r = V.size();
		int u, v, lx, rx;
		scanf("%d%d", &u, &v);
		while (r - l > 1) {
			int c = (l + r) / 2;
			if (V[c].x - V[c].y < u - v) {
				l = c;
			}
			else {
				r = c;
			}
		}
		lx = V[l].x;
		l = 0, r = V.size() - 1;
		while (r - l > 1) {
			int c = (l + r) / 2;
			if (V[c].x + V[c].y > u + v) {
				r = c;
			}
			else {
				l = c;
			}
		}
		rx = V[r].x;
		printf("%d %d\n", lx, rx);
	}
}



int main() {
#pragma comment(linker,"/STACK:536870912")
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	freopen("mountain.in", "rt", stdin);
	freopen("mountain.out", "wt", stdout);
#endif
	scanf("%d%d", &n, &q);
	bool g1 = true;
	for (int i = 0; i < n; ++i) {
		ll d;
		scanf("%lld%lld", &d, &k[i]);
		if (abs(k[i]) != 1) g1 = false;
		if (i == 0) {
			p[i].x = 0;
			p[i].y = 0;
		}
		p[i + 1].x = p[i].x + d;
		p[i + 1].y = p[i].y + k[i] * d;
	}
	if (g1) {
		solve1();
		return 0;
	}
	if ((ll)n*q < 10000000) {
		solveNQ();
	}
	return 0;
}