#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stdio.h>
#include <cmath>
#include <map>
#include <time.h>
#include <cstdio>

using namespace std;

const int N = 100000;
int x[N], y[N];
int k[N], d[N];

int main()
{
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	
	int n, q;
	cin >> n >> q;
	x[0] = 0; y[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> d[i] >> k[i];
		x[i] = x[i - 1] + d[i];
		y[i] = y[i - 1] + k[i] * d[i];
	}

	for (int z = 0; z < q; z++) {
		int a, b;
		cin >> a >> b;
		
		for (int i = 0; i <= n; i++) {
			double max_tg = -100000000;
			for (int j = i + 1; j <= n; j++) {
				if (x[i] < a && x[j] < a) {
					max_tg = max(max_tg, (double)(y[j] - y[i]) / (x[j] - x[i]));
				}
			}
			if (max_tg < (double)(b - y[i]) / (a - x[i])) {
				cout << x[i] << " ";
				break;
			}
		}
		
		for (int i = n; i >= 0; i--) {
			double max_tg = 100000000;
			for (int j = i - 1; j >= 0; j--) {
				if (x[i] > a && x[j] > a) {
					max_tg = min(max_tg, (double)(y[i] - y[j]) / (x[i] - x[j]));
				}
			}
			if (max_tg > (double)(y[i] - b) / (x[i] - a)) {
				cout << x[i] << endl;
				break;
			}
		}
	}

	//for (;;);
}

/*

6 1
3 1
2 -1
1 1
1 -1
1 1
2 -1
5 3

*/
