#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#include<set>
#include<cassert>
#include<vector>
using namespace std;
const int MAXN = 400 * 1000 + 7;
struct ray
{
	long long x, y;
	ray(long long dx, long long dy)
	{
		x = dx;
		y = dy;
	}
};
bool bad(ray a, ray b)
{
	return a.y*b.x - a.x*b.y > 0;
}
long long x[MAXN], y[MAXN];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	int n, q;
	scanf("%d %d", &n, &q);
	x[1] = 0;
	y[1] = 0;
	n++;
	for (int i = 2; i <= n; i++)
	{
		long long d, k;
		scanf("%lld %lld", &d, &k);
		x[i] = x[i - 1] + d;
		y[i] = y[i - 1] + d*k;
	}
	for (int i = 1; i <= q; i++)
	{
		long long X, Y;
		scanf("%lld %lld", &X, &Y);
		int lpos = 0;
		for (int j = 1; j <= n; j++)
		{
			if (x[j] <= X) lpos = j;
		}
		int rpos = 0;
		for (int j = n; j >= 1; j--)
		{
			if (x[j] >= X) rpos = j;
		}
		ray cur = ray(X - x[lpos], Y - y[lpos]);
		long long lastX = x[lpos];
		for (int j = lpos - 1; j >= 0; j--)
		{
			ray go = ray(X - x[j], Y - y[j]);
			if (j == 0 || bad(go, cur))
			{
				printf("%lld ", lastX);
				break;
			}
			else
			{
				cur = go;
				lastX = x[j];
			}
		}
		cur = ray(x[rpos] - X, Y - y[rpos]);
		lastX = x[rpos];
		for (int j = rpos + 1; j <= n + 1; j++)
		{
			ray go = ray(x[j] - X, Y - y[j]);
			if (j == n + 1 || bad(go, cur))
			{
				printf("%lld\n", lastX);
				break;
			}
			else
			{
				cur = go;
				lastX = x[j];
			}
		}
	}
}