#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <functional>
#include <map>
#include <queue>

#define ll long long
#define ld long double
#define mp make_pair
#define TASKNAME "mountain"

using namespace std;

const ll inf = 1e18;
const ll infLL = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

struct point {
	ll x, y;
	point() : x(0), y(0) { }
	point(ll x, ll y) : x(x), y(y) { }
};

void solve() {
	int n, q;
	cin >> n >> q;
	vector<point> a(n + 1);
	for (int i = 0; i < n; i++) {
		ll d, k;
		cin >> d >> k;
		a[i + 1] = point(a[i].x + d, a[i].y + k * d);
	}
	for (int qi = 0; qi < q; qi++) {
		point c;
		cin >> c.x >> c.y;
		int p1 = 0, p2 = 0;
		for (int i = 0; i < n; i++) {
			if (a[i].x <= c.x && c.x <= a[i + 1].x) {
				p1 = i;
				p2 = i + 1;
				break;
			}
		}
		int ans1 = 0;
		for (int i = p1; i >= 0; i--) {
			ans1 = i;
			if (i == 0)
				break;
			int ni = i - 1;
			ld k1 = infLL;
			if (c.x != a[i].x)
				k1 = (ld)(c.y - a[i].y) / (ld)(c.x - a[i].x);
			//k1 = abs(k1);
			ld k2 = infLL;
			if (c.x != a[ni].x)
				k2 = (ld)(c.y - a[ni].y) / (ld)(c.x - a[ni].x);
			//k2 = abs(k2);
			if (k1 < k2)
				break;
		}
		int ans2 = 0;
		for (int i = p2; i <= n; i++) {
			ans2 = i;
			if (i == n)
				break;
			int ni = i + 1;
			ld k1 = -infLL;
			if (c.x != a[i].x)
				k1 = (ld)(c.y - a[i].y) / (ld)(c.x - a[i].x);
			//k1 = abs(k1);
			ld k2 = infLL;
			if (c.x != a[ni].x)
				k2 = (ld)(c.y - a[ni].y) / (ld)(c.x - a[ni].x);
			//k2 = abs(k2);
			if (k1 > k2)
				break;
		}
		cout << a[ans1].x << " " << a[ans2].x << endl;
	}
}

int main() {
#ifdef __DEBUG__
	freopen("input.txt", "r", stdin);
	clock_t start = clock();
#else
	freopen(TASKNAME".in", "r", stdin);
	freopen(TASKNAME".out", "w", stdout);
#endif 

	solve();

#ifdef __DEBUG__
	cerr << "\nTime: " << (ld)(clock() - start) / (ld)CLOCKS_PER_SEC << endl;
#endif
}