#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

struct po {
	int x, y;
	po() {}
	po(int x, int y) {
		this->x = x;
		this->y = y;
	}
};

inline int operator %(po v1, po v2) {
	return v1.x * v2.y - v1.y * v2.x;
}

inline po operator -(po v1, po v2) {
	return po(v1.x - v2.x, v1.y - v2.y);
}

int n, q, c, d, k[100500];
po a[100500], e;
pair <pair <long, long>, int> b[100500];
pair <int, int> otv[100500];

int main() {
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> q;
	a[0] = po(0, 0);
	for (int i = 1; i <= n; i++) {
		cin >> d >> k[i];
		a[i] = po(a[i - 1].x + d, a[i - 1].y + d * k[i]);
	}
	bool ind = 1;
	for (int i = 0; i < q; i++) {
		cin >> b[i].first.first >> b[i].first.second;
		b[i].second = i;
		otv[i].second = n;
	}
	for (int i = 1; i < q; i++) {
		if (b[i].first.first != b[i - 1].first.first) {
			ind = 0;
		}
	}
	int l, r;
	if (!ind) {
		for (int i = 0; i < q; i++) {
			e = po(b[i].first.first, b[i].first.second);
			//cin >> e.x >> e.y;
			l = 0, r = n;
			if (e.x == a[n].x) {
				l = r;
			}
			while (r - l > 1) {
				if (a[(r + l) / 2].x <= e.x) {
					l = (r + l) / 2;
				}
				else {
					r = (r + l) / 2;
				}
			}
			int ans = 0;
			for (int i = l; i > 0; i--) {
				if (a[i].y + k[i] * (e.x - a[i].x) > e.y) {
					ans = i;
					break;
				}
			}
			cout << a[ans].x << " ";
			ans = n;
			for (int i = r; i < n; i++) {
				if (a[i].y + k[i + 1] * (e.x - a[i].x) > e.y) {
					ans = i;
					break;
				}
			}
			cout << a[ans].x << endl;
		}
		return 0;
	}
	l = 0;
	r = n;
	e = po(b[0].first.first, b[0].first.second);
	if (e.x == a[n].x) {
		l = r;
	}
	while (r - l > 1) {
		if (a[(r + l) / 2].x <= e.x) {
			l = (r + l) / 2;
		}
		else {
			r = (r + l) / 2;
		}
	}
	sort(b, b + q);
	int no = 0;
	for (int i = l; i > 0; i--) {
		while (no < q && a[i].y + k[i] * (e.x - a[i].x) > b[no].first.second) {
			otv[b[no].second].first = i;
			no++;
		}
	}
	no = 0;
	for (int i = r; i < n; i++) {
		while (no < q && a[i].y + k[i + 1] * (e.x - a[i].x) > b[no].first.second) {
			otv[b[no].second].second = i;
			no++;
		}
	}
	for (int i = 0; i < q; i++) {
		cout << a[otv[i].first].x << " " << a[otv[i].second].x << endl;
	}
}