#define consfl 0
#define fname "mountain"

#include <iostream>
#include <cstdio>
#include <cstdlib>

#include <algorithm>
#include <cmath>

#include <vector>
#include <set>

#define forn(i, n) for (int i = 0; i < n; i ++)
#define fornn(i, n, m) for (int i = n; i < m; i ++)
#define mk make_pair
#define outb pop_back
#define inb push_back
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

using namespace std;

const int dd = 1e5;
const ld eps = 1e-8;


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	if (!consfl) {
		freopen(fname".in", "r", stdin);
		freopen(fname".out", "w", stdout);
	}
#endif
	int n, q;
	cin >> n >> q;
	pair<ld, ld> now;
	vector<pair<ld, ld> > qwe;
	qwe.inb(now);
	forn(i, n) {
		ld d, k;
		cin >> d >> k;
		qwe.inb(mk(now.X + d, now.Y + k * d));
		now = qwe.back();
	}
	forn(qq, q) {
		int x, y;
		cin >> x >> y;
		int r = qwe.size() - 1;
		while (r > 0) {
			bool fl = 1;
			for (int i = r - 1; qwe[i].X >= x; i--) {
				ld d = qwe[r].X - x;
				ld k = (qwe[r].Y - y) / d;
				d = qwe[r].Y - (k * qwe[r].X);
				ld a = k;
				ld b = -1;
				ld c = d;
				ld len = (a * qwe[i].X + b * qwe[i].Y + c) / (a * a + b * b);
				if ((len + eps > 0) != (c + eps > 0)) {
					fl = 0;
					break;
				}
			}
			if (fl) {
				break;
			}
			r--;
		}

		int l = 0;
		while (l < qwe.size()) {
			bool fl = 1;
			for (int i = l + 1; qwe[i].X < x; i++) {
				ld d = x - qwe[l].X;
				ld k = (y - qwe[l].Y) / d;
				d = y - (k * x);
				ld a = k;
				ld b = -1;
				ld c = d;
				ld len = (a * qwe[i].X + b * qwe[i].Y + c) / (a * a + b * b);
				if ((len + eps > 0) != (c + eps > 0)) {
					fl = 0;
					break;
				}
			}
			if (fl) {
				break;
			}
			l++;
		}
		cout << qwe[l].X << ' ' << qwe[r].X << endl;
	}
	return 0;
}