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

using namespace std;

struct po {
	long long x, y;
	po() {}
	po(long long x, long long y) {
		this->x = x;
		this->y = y;
	}
	pair <long double, long double> p() {
		return make_pair(x, y);
	}
};

inline long long 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);
}

long long n, q, c, d, k[100500];
po a[100500], e;
pair <pair <long long, long long>, int> b[100500];
pair < pair <long double, long double>, int> br[100500];
long double kr[100500];
pair <long double, long double> ar[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];
		kr[i] = k[i];
		a[i] = po(a[i - 1].x + d, a[i - 1].y + d * k[i]);
		ar[i] = a[i].p();
	}
	bool ind = 1, ind1 = 1;
	for (int i = 0; i < q; i++) {
		cin >> b[i].first.first >> b[i].first.second;
		b[i].second = i;
		br[i] = b[i];
		otv[i].second = n;
	}
	for (int i = 1; i < q; i++) {
		if (b[i].first.first != b[i - 1].first.first) {
			ind = 0;
		}
		if (b[i].first.second != b[i - 1].first.second) {
			ind1 = 0;
		}
	}
	int l, r, no;
	if ((!ind && !ind1) || (q < 4000 && n < 4000)) {
		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;
	}
	if (ind) {
		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);
		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;
		}
		return 0;
	}
	sort(b, b + q);
	no = q - 1;
	long long sd;
	for (int i = n; i > 0; i--) {
		if (no == - 1 || k[i] < 0 || a[i].x > b[no].first.first) {
			continue;
		}
		sd = a[i].y - k[i] * a[i].x;
		while (no > -1 && b[no].first.first * k[i] + sd > b[no].first.second) {
			otv[b[no].second].first = i;
			no--;
		}
	}
	no = 0;


	for (int i = 0; i < n; i++) {
		if (no == q || k[i + 1] > 0 || a[i].x < b[no].first.first) {
			continue;
		}
		sd = a[i].y - k[i + 1] * a[i].x;
		while (no != q && b[no].first.first * k[i + 1] + sd > 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;
	}
}