#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <fstream>

using namespace std;

struct point {
	long long x, y;
	point() {};
	point(long long X, long long Y) {
		x = X;
		y = Y;
	}
};

long long vect(point a, point b, point c) {
	return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}

long long n, q;
vector <point> v;

int main() {
	//ifstream cin("in.txt");
	//ofstream cout("out.txt");
	ifstream cin("mountain.in");
	ofstream cout("mountain.out");
	ios_base::sync_with_stdio(false);
	cin >> n >> q;
	v.push_back(point(0, 0));
	for (int i = 1; i <= n; i++) {
		long long d, k;
		cin >> d >> k;
		v.push_back(point(v[i - 1].x + d, v[i - 1].y + k * d));
	}
	v.push_back(point(1e9, 0));
	for (int i = 1; i <= q; i++) {
		long long x, y, nom1, nom2;
		cin >> x >> y;
		point p = point(x, y);
		for (int j = 0; j < v.size(); j++)
			if (v[j].x <= x && v[j + 1].x >= x) {
				nom1 = j;
				nom2 = j + 1;
			}
		bool flag = true;
		for (int j = nom1 - 1; j >= 0; j--) 
			if (vect(p, v[j], v[j + 1]) < 0) {
				cout << v[j + 1].x << " ";
				flag = false;
				break;
			}
		if (flag)
			cout << v[0].x << " ";
		flag = true;
		for (int j = nom2 + 1; j < v.size(); j++)
			if (vect(p, v[j], v[j - 1]) > 0) {
				cout << v[j - 1].x << endl;
				flag = false;
				break;
			}
		if (flag)
			cout << v[v.size() - 2].x << endl;
	}
	return 0;
}