#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

struct point {
	double x, y;
	point() {}
	point(double x, double y) : x(x), y(y) {}
};

point a[400005];
ll n, q;

double an(point a, point b) {
	return acosl((a.y - b.y) / sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));		
}

ll findl(int x) {
	ll res = 0;
	for (int i = 1; i <= n; i++)
		if (a[i].x <= x) res = i;
		else break;
	return res;
}

ll findr(int x) {
	ll res = n;
	for (int i = n - 1; i >= 0; i--)
		if (a[i].x >= x) res = i;
		else break;
	return res;
}

inline bool less2(double a, double b) {
	return a + 1e-14 < b;
}

int main() {
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	cin >> n >> q;
	a[0] = point(0, 0);
	for (int i = 1; i <= n; i++) {
		double d, k;
		cin >> d >> k;
		a[i] = point(a[i - 1].x + d, a[i - 1].y + k * d);
	}
	while (q--) {
		point p;
		cin >> p.x >> p.y;
		ll l = findl(p.x);
		ll r = findr(p.x);
		double b = 0;
		bool f = false;
		for (l--; l >= 0; l--) {
			if (less2(an(p, a[l]), b)) {
				double du = an(p, a[l]);
				cout << a[l + 1].x << ' ';
				f = true;
				break;
			}
			b = an(p, a[l]);
		}
		if (!f) cout << 0 << ' ';
		f = false;
		b = 0;
		for (r++; r <= n; r++) {
			if (less2(an(p, a[r]), b)) {
				cout << a[r - 1].x << endl;
				f = true;
				break;
			}
			b = an(p, a[r]);
		}
		if (!f) cout << a[n].x << endl;
	}
	return 0;
}