#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 && qwe[r].X > x)
			r--;
		r++;
		int rr = r;
		while (r <= qwe.size() - 1) {
			bool fl = 1;
			for (int i = rr; i < r; i++) {
				ld x1 = qwe[r].X - x;
				ld y11 = qwe[r].Y - y;
				ld x2 = qwe[i].X - x;
				ld y2 = qwe[i].Y - y;
				ld vec = (x1 * y2 - x2 * y11);
				if (vec - eps > 0) {
					fl = 0;
					break;
				}
			}
			if (!fl) {
				break;
			}
			r++;
		}
		r--;
		int l = 0;
		while (l < qwe.size() && qwe[l].X < x)
			l++;
		l--;
		int ll = l;
		while (l >= 0) {
			bool fl = 1;
			for (int i = ll; i > l; i--) {
				ld x1 = x - qwe[l].X;
				ld y11 = y - qwe[l].Y;
				ld x2 = qwe[i].X - qwe[l].X;
				ld y2 = qwe[i].Y - qwe[l].Y;
				ld vec = (x1 * y2 - x2 * y11);
				if (vec - eps > 0) {
					fl = 0;
					break;
				}
			}
			if (!fl) {
				break;
			}
			l--;
		}
		l++;
		cout << qwe[l].X << ' ' << qwe[r].X << endl;
	}
	return 0;
}