#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], Q[400400];
ll k[400400];
int n, q;

bool visR(int pos, pair<ll, ll> t) {
	if (pos == n) {
		return false;
	}
	if (p[pos].x <= t.x) return true;
	return (p[pos].y - t.y) * (p[pos + 1].x - t.x) <= (p[pos + 1].y - t.y) * (p[pos].x - t.x);
}

bool visL(int pos, pair<ll, ll> t) {
	if (pos == 0) {
		return false;
	}
	if (p[pos].x >= t.x) return true;
	return (t.y - p[pos].y) * (t.x - p[pos - 1].x) >= (t.y - p[pos - 1].y) * (t.x - p[pos].x);
}

void solveNQ() {
	for (int i = 0; i < q; ++i) {
		ll u, v;
		u = Q[i].x;
		v = Q[i].y;
		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() {
	map<int, int> sm, sb;
	for (int i = 0; i < n; ++i) {
		if (k[i] == -1) {
			sm[p[i].x + p[i].y] = i;
		}
	}
	for (int i = n; i > 0; --i) {
		if (k[i - 1] == 1) {
			sb[p[i].y - p[i].x] = i;
		}
	}
	for (int i = 0; i < q; ++i) {
		int u, v, lx, rx;
		u = Q[i].x;
		v = Q[i].y;
		auto it = sm.upper_bound(u + v);
		if (it == sm.end()) {
			rx = p[n].x;
		}
		else {
			rx = p[it->y].x;
		}
		it = sb.upper_bound(v - u);
		if (it == sb.end()) {
			lx = 0;
		}
		else {
			lx = p[it->y].x;
		}
		printf("%d %d\n", lx, rx);
	}
}

void solvex() {
	vector<int> ind(q), ansl(q), ansr(q);
	for (int i = 0; i < q; ++i) {
		ind[i] = i;
	}
	sort(ind.begin(), ind.end(), [&](int a, int b) {return Q[a] < Q[b]; });
	int R = 0;
	for (int i = 0; i < q; ++i) {
		while (visR(R, Q[ind[i]])) ++R;
		ansr[ind[i]] = R;
	}
	int L = n;
	for (int i = q - 1; i >= 0; --i) {
		while (visL(L, Q[ind[i]])) --L;
		ansl[ind[i]] = L;
	}
	for (int i = 0; i < q; ++i) {
		printf("%lld %lld\n", p[ansl[i]].x, p[ansr[i]].x);
	}
}

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;
	map<ll, int> Y;
	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;
	}
	for (int i = 0; i < q; ++i) {
		scanf("%lld%lld", &Q[i].x, &Q[i].y);
		Y[Q[i].y] = 1;
	}
	//if (g1) {
	//	solve1();
	//	return 0;
	//}
	//if ((ll)n*q < 10000000) {
	//	solveNQ();
	//	return 0;
	//}
	if (Y.size() == 1) {
		solvex();
		return 0;
	}
	return 0;
}