#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define MAXN 100007

typedef long long slong;


struct pt {
	slong x, y;

	pt() :x(0), y(0) {}
	pt(slong x, slong y) :x(x), y(y) {}
};

const pt operator +(pt a, pt b) {
	return pt(a.x+b.x, a.y+b.y);
}
const pt operator -(pt a, pt b) {
	return pt(a.x-b.x, a.y-b.y);
}
const slong operator &(pt a, pt b) {
	return a.y*b.x-a.x*b.y;
}





int n, q;
pt mnt[MAXN];
pt vars[MAXN];


void solver(pt p) {
	int ls, rs;
	slong ansl, ansr;
	for (int i=0; i<n; i++) {
		if (i==n || mnt[i].x >= p.x) {
			rs = i;
			ls = i-1;
			break;
		}
	}
	while (ls > 0) {
		pt a = mnt[ls]-p;
		pt b = mnt[ls-1]-p;
		if ((a & b) >= 0) {
			ls--;
		} else {
			break;
		}
	}
	if (ls != 0) {
		slong sl = mnt[ls-1].x;
		slong sr = mnt[ls].x;
		slong y0 = mnt[ls-1].y;
		slong k0 = (mnt[ls].y-mnt[ls-1].y) / (mnt[ls].x-mnt[ls-1].x);
		while (sl < sr) {
			pt a = mnt[ls]-p;
			slong m = (sl+sr) >> 1;
			pt b = pt(m, y0 + k0 * m)-p;
			if ((a & b) > 0) {
				sr = m;
			} else {
				sl = m+1;
			}
		}
		ansl = sl;
	} else {
		ansl = 0;
	}

	while (rs < n-1) {
		pt a = mnt[rs]-p;
		pt b = mnt[rs+1]-p;
		if ((a & b) <= 0) {
			rs++;
		} else {
			break;
		}
	}
	if (rs != n-1) {
		slong sl = mnt[rs].x;
		slong sr = mnt[rs+1].x;
		slong y0 = mnt[rs].y;
		slong k0 = (mnt[rs].y-mnt[rs+1].y) / (mnt[rs].x-mnt[rs+1].x);
		while (sl < sr) {
			pt a = mnt[rs]-p;
			slong m = (sl+sr) >> 1;
			pt b = pt(m, y0 + k0 * m)-p;
			if ((a & b) < 0) {
				sl = m+1;
			} else {
				sr = m;
			}
		}
		ansr = sl;
	} else {
		ansr = mnt[n-1].x;
	}
	printf("%lld %lld\n", ansl, ansr);
}








int main() {
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);

	scanf("%d%d", &n, &q);
	mnt[0] = pt(0, 0);
	for (int i=1; i<=n; i++) {
		int d, k;
		scanf("%d%d", &d, &k);
		mnt[i] = mnt[i-1] + pt(d, slong(k)*slong(d));
	}
	n++;
	for (int i=0; i<q; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		solver(pt(x, y));
	}
}


