#include<iostream>
#include<time.h>
#include<algorithm>
#include<string>
#include<map>
using namespace std;


//ifstream cin("robots.in");
//ofstream cout("robots.out");

int main() {
	long long i, j,n,q,k[1001],d[1001],x[1001],y[1001],m1,m2,x1,y1;
	double k1,k2;
	cin >> n >> q;
	x[0] = 0;
	y[0] = 0;
	for (i = 1; i <= n; i++) {
		cin >> d[i] >> k[i];
		x[i] = x[i - 1] + d[i];
		y[i] = y[i - 1] + k[i] * d[i];
	}
	while (q > 0) {
		q--;
		cin >> x1 >> y1;
		m1 = 0;
		if (x1 != 0) {
			k1 =double (y1 - y[0]) / double(x1 - x[0]);
			for (i = 1; i <= n && x[i] < x1; i++) {
				k2 =double (y1 - y[i]) / double(x1 - x[i]);
				if (k1 >= k2)
					m1 = x[i];
				k1 = k2;
				j = i;
			}
		}
		m2 = x[n];
		if(x1!=x[n]){
		k1 = double(y[n]-y1) / double(x[n]-x1);
		for (i = n-1; i>=0 && x[i] > x1; i--) {
			k2 =double (y[i]-y1) / double(x[i]-x1);
			if (k1 <= k2)
				m2 = x[i];
			k1 = k2;
			j = i;
		}
	}
		cout << m1 << ' ' << m2<<endl;
	}
	system("pause");
	return 0;

}