#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <map>
#include <queue>

using namespace std;

#define vec vector
#define ALL(x) (x).begin(), (x).end()
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair< int, int > pii;

const int inf = 1000 * 1000 * 1000;
const ll inf64 = 1ll * inf * inf;

bool solve() {

	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);

	int n, q;

	scanf("%d %d", &n, &q);

	vec< int > d(n + 1), k(n + 1), x(n + 1), y(n + 1);

	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &d[i], &k[i]);
		x[i] = x[i - 1] + d[i];
		y[i] = y[i - 1] + k[i] * d[i];
	}
	
	vec< int > l(n + 1), r(n + 1);

	for (int i = 2; i <= n; i++) {
		int x1, y1, x2, y2;
		x1 = x[i] - x[i - 1];
		y1 = y[i] - y[i - 1];
		x2 = x[i - 2] - x[i - 1];
		y2 = y[i - 2] - y[i - 1];
		if (1ll * x1 * y2 - 1ll * x2 * y1 >= 0) {
			l[i] = l[i - 1];
		}
		else l[i] = x[i - 1];
	}

	r[n] = r[n - 1] = x[n];

	for (int i = n - 2; i >= 0; i--) {
		int x1, y1, x2, y2;
		x1 = x[i + 2] - x[i + 1];
		y1 = y[i + 2] - y[i + 1];
		x2 = x[i] - x[i + 1];
		y2 = y[i] - y[i + 1];
		if (1ll * x1 * y2 - 1ll * x2 * y1 >= 0) {
			r[i] = r[i + 1];
		} else r[i] = x[i + 1];
	}
 
	for (int u, v, i = 0; i < q; i++) {
		scanf("%d %d", &u, &v);
		int x1, y1, x2, y2;
		int il = upper_bound(ALL(x), u) - x.begin() - 1;
		int ir = lower_bound(ALL(x), u) - x.begin();
		if (il == 0) printf("0 ");
		else if(u == x[il]) {
			printf("%d ", l[il]);
		} else {
			x1 = u - x[il];
			y1 = v - y[il];
			x2 = x[il - 1] - x[il];
			y2 = y[il - 1] - y[il];
			if (1ll * x1 * y2 - 1ll * x2 * y1 >= 0) printf("%d ", l[il]);
			else printf("%d ", x[il]);
		}
		if (ir == n) printf("%d\n", x[n]);
		else if (u == x[ir]) printf("%d\n", r[ir]);
		else {
			x1 = x[ir + 1] - x[ir];
			y1 = y[ir + 1] - y[ir];
			x2 = u - x[ir];
			y2 = v - y[ir];
			if (1ll * x1 * y2 - 1ll * x2 * y1 >= 0) printf("%d\n", r[ir]);
			else printf("%d\n", x[ir]);
		}
	}

	return true;
}

int main() {

	//while (solve());
	solve();

	return 0;
}