#include<fstream>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<time.h>

using namespace std;

typedef long long ll;
const int maxn = 400005;
const ll inf = 2000000000000000000;

struct point {
	ll x, y;
	point() {};
	point(ll _x, ll _y) { x = _x; y = _y; }
	point operator-(point a) {
		return point(x - a.x, y - a.y);
	}
};
struct vect {
	ll x, y;
	vect() {};
	vect(ll _x, ll _y) { x = _x; y = _y; }
	vect(point a) { x = a.x; y = a.y; }
	ll operator*(vect a) {
		return x*a.y - y*a.x;
	}
};

int n, q;
point arr[maxn];

int main() {
	ifstream cin("mountain.in");
	ofstream cout("mountain.out");
	ios_base::sync_with_stdio(false);
	ll xp = 0, yp = 0;
	cin >> n >> q;
	n += 1;
	for (int i = 2; i <= n; ++i) {
		ll d, k;
		cin >> d >> k;
		arr[i] = point(xp + d, yp + k*d);
		xp = arr[i].x; yp = arr[i].y;
	}
	for (int i = 1; i <= q; ++i) {
		ll x, y;
		cin >> x >> y;
		point pt = point(x, y);
		ll l = 0, r = arr[n].x, ly=0, ry=0;
		int nl=0, nr=n;
		bool bol = true;
		while (l < n && bol) {
			int k = n;
			while (k > 0 &&  arr[k].x >= l && bol) {
				if (vect(arr[k] - pt)*vect(point(l, ly) - pt) < 0)  
					bol = false;
				k -= 1;
			}
			if (bol) {
				nl += 1;
				l = arr[nl].x; ly = arr[nl].y;
			}
		}
		bol = true;
		while (r > 0 && bol) {
			int k = 0;
			while (k < n && arr[k].x <= l && bol) {
				if (vect(arr[k] - pt)*vect(point(r, ry) - pt) < 0)  bol = false;
				k += 1;
			}
			if (bol) {
				nr -= 1;
				r = arr[nr].x; ry = arr[nr].y;
			}
		}
		cout << r << " " << l << endl;
	}

	return 0;
}