#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stdio.h>
#include <list>
#include <algorithm>
#pragma warning(disable: 4996)
typedef long long ll;
typedef long double ld;
using namespace std;

const ll SZ = 1e3 + 10;
const ll INF = 1e9;

map<ll, ll> a; // { x, y }

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
#endif
	srand(753424635);

	ll n, q;
	cin >> n >> q;
	ll x = 0, y = 0;
	for (ll i = 0; i < n; i++) {
		ll d, k;
		cin >> d >> k;
		x += d;
		y += d * k;
		a[x] = y;
	}
	a[0] = 0;

	while (q--) {
		pair<ll, ll> ans;
		ll x, y;
		cin >> x >> y;
		auto e = a.lower_bound(x);
		ll xlast = e->first, ylast = e->second;
		while (true) {
			e++;
			if (e == a.end())
				break;
			if (e->first * ylast - e->second * xlast + xlast * y - ylast * x + x * e->second - y * e->first > 0)
				break;
			xlast = e->first, ylast = e->second;
		}
		ans.second = xlast;

		e = a.upper_bound(x);
		e--;
		xlast = e->first, ylast = e->second;
		while (true) {
			if (e == a.begin())
				break;
			e--;
			if (e->first * ylast - e->second * xlast + xlast * y - ylast * x + x * e->second - y * e->first < 0)
				break;
			xlast = e->first, ylast = e->second;
		}
		ans.first = xlast;

		cout << ans.first << " " << ans.second << "\n";
	}

	return 0;
}