#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
const int lim = 100010;

struct Point {
	ll x, y;
	Point() {}
	Point(ll x, ll y) : x(x), y(y) {}
};

Point points[lim];
int psize = 1;
ll ks[lim];
Point query[lim];
//ll ololo[lim];
//int index[lim];
int sorted[lim];
int ans[lim];
/*Point add1[lim], add2[lim];
int size1 = 0, size2 = 0;*/

bool comp(int const &a, int const &b) {
	return query[a].y < query[b].y;
}

bool comp2(int const &a, int const &b) {
	return query[a].x < query[b].x;
}

int main() {
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	int n, q, i, j;
	ll x, y = 0, k, prevx = 0;
	bool cond1 = true, cond2 = true, cond3 = true;
	points[0] = Point(0, 0);
	scanf("%d %d", &n, &q);
	for (i = 0; i < n; ++i) {
		scanf("%lld %lld", &x, &k);
		if (abs(k) != 1)
			cond1 = false;
		ks[i] = k;
		points[psize] = Point(prevx + x, y + x * k);
		y = points[psize].y;
		prevx += x;
		++psize;
	}
	for (i = 0; i < q; ++i) {
		scanf("%lld %lld", &query[i].x, &query[i].y);
		if (i && query[i].x != query[i - 1].x)
			cond2 = false;
		if (i && query[i].y != query[i - 1].y)
			cond3 = false;
	}
	if (!(cond2 || cond3)) {
		for (i = 0; i < q; ++i) {
			int resl = -1, resr = n + 1;
			for (j = 0; j < n - 1; ++j)
				if (points[j].x < query[i].x && query[i].y - points[j].y < (query[i].x - points[j].x) * ks[j])
					resl = j;
			for (j = n; j; --j)
				if (points[j].x > query[i].x && query[i].y - points[j].y < (query[i].x - points[j].x) * ks[j - 1])
					resr = j;
			printf("%lld %lld\n", points[resl + 1].x, points[resr - 1].x);
		}
		return 0;
	}
	if (cond2) {
		x = query[0].x;
		int l = 0, r = n;
		for (i = 0; i <= n; ++i)
			if (points[i].x < x) {
				//ololo[i] = ks[i] * (x - points[i].x) + points[i].y;
				l = i;
			}
			else
				break;
		for (i = n; i >= 0; --i)
			if (points[i].x > x) {
				//ololo[i] = ks[i - 1] * (x - points[i].x) + points[i].y;
				r = i;
			}
			else
				break;
		for (i = 0; i < q; ++i)
			sorted[i] = i;
		sort(sorted, sorted + q, comp);
		for (j = 0; j < q; ++j) {
			i = sorted[j];
			//index[i] = j;
			while (l >= 0)
				if (query[i].y - points[l].y >= (query[i].x - points[l].x) * ks[l])
					--l;
				else
					break;
			while (r <= n)
				if (query[i].y - points[r].y >= (query[i].x - points[r].x) * ks[r - 1])
					++r;
				else
					break;
			query[i] = Point(l, r);
		}
		for (i = 0; i < q; ++i)
			printf("%lld %lld\n", points[query[i].x + 1].x, points[query[i].y - 1].x);
		return 0;
	}
	if (cond3) {
		x = query[0].x;
		for (i = 1; i < q; ++i)
			if (x > query[i].x)
				x = query[i].x;
		y = query[0].x;
		for (i = 1; i < q; ++i)
			if (y < query[i].x)
				y = query[i].x;
		int l = 0, r = n;
		for (i = n; i >= 0; --i)
			if (points[i].x > x) {
				//ololo[i] = ks[i - 1] * (x - points[i].x) + points[i].y;
				r = i;
			}
			else
				break;
		for (i = 0; i <= n; ++i)
			if (points[i].x < y) {
				//ololo[i] = ks[i - 1] * (x - points[i].x) + points[i].y;
				l = i;
			}
			else
				break;
		for (i = 0; i < q; ++i)
			sorted[i] = i;
		sort(sorted, sorted + q, comp2);
		for (j = 0; j < q; ++j) {
			i = sorted[j];
			while (r <= n)
				if (points[r].x < query[i].x || query[i].y - points[r].y >= (query[i].x - points[r].x) * ks[r - 1])
					++r;
				else
					break;
			ans[i] = r;
		}
		for (j = q - 1; j >= 0; --j) {
			i = sorted[j];
			while (l >= 0)
				if (points[l].x > query[i].x || query[i].y - points[l].y >= (query[i].x - points[l].x) * ks[l])
					--l;
				else
					break;
			query[i].x = l;
		}
		for (i = 0; i < q; ++i)
			printf("%lld %lld\n", points[query[i].x + 1].x, points[ans[i] - 1].x);
		return 0;
	}

	return 0;
}