#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstdlib>
#include <vector>
#define ll long long
using namespace std;

const int MAXN = 1e5 + 111;

struct Point
{
	int x, y;
	Point() {}
	Point(int x, int y) : x(x), y(y) {}
};

struct Vector
{
	int x, y;
	Vector() {}
	Vector(int x, int y) : x(x), y(y) {}
	Vector(Point a, Point b)
	{
		x = b.x - a.x;
		y = b.y - a.y;
	}
};

int n, q;

int d[MAXN], k[MAXN];

int x[MAXN], y[MAXN];

vector <Point> v;

ll cp(Vector a, Vector b)
{
	return (ll)a.x * b.y - (ll)a.y * b.x;
}

void right(int xx, int yy)
{
	Point p(xx, yy);
	int id;
	for (int i = 0; i <= n; i++)
	{
		if (x[i] > p.x)
		{
			id = i;
			break;
		}
	}
	if (id == -1)
		id = n;
	Vector cur(0, 0);
	for (; id <= n; id++)
	{
		if (cp(cur, Vector(p, v[id])) >= 0)
			cur = Vector(p, v[id]);
		else
		{
			printf("%d\n", v[id - 1].x);
			return;
		}
	}
	printf("%d\n", v[n].x);
}

void left(int xx, int yy)
{
	Point p(xx, yy);
	int id = -1;
	for (int i = n; i >= 0; i--)
	{
		if (x[i] < p.x)
		{
			id = i;
			break;
		}
	}
	if (id == -1)
		id = 0;
	Vector cur(0, 0);
	for (; id >= 0; id--)
	{
		if (cp(cur, Vector(p, v[id])) <= 0)
			cur = Vector(p, v[id]);
		else
		{
			printf("%d ", v[id + 1].x);
			return;
		}
	}
	printf("%d ", v[0].x);
}

bool operator <(Point a, Point b)
{
	return a.x < b.x;
}

bool canl(int id, Point p)
{
	if (v[id].x >= p.x)
		return false;
	return v[id].y + k[id + 1] * abs(v[id].x - p.x) <= p.y;
}

int binl(int l, int r, Point p)
{
	while (l != r - 1)
	{
		int mid = (l + r) / 2;
		if (canl(mid, p))
			r = mid;
		else
			l = mid;
	}
	return r;
}

void leftt(int xx, int yy)
{
	Point p(xx, yy);
	int r = upper_bound(v.rbegin(), v.rend(), p) - v.rbegin();
	int id = binl(-1, r + 1, p);
	printf("%d ", v[id].x);
}

bool canr(int id, Point p)
{
	if (v[id].x <= p.x)
		return false;
	return v[id].y + (-1) * k[id] * abs(v[id].x - p.x) <= p.y;
}

int binr(int l, int r, Point p)
{
	while (l != r - 1)
	{
		int mid = (l + r) / 2;
		if (canr(mid, p))
			l = mid;
		else
			r = mid;
	}
	return l;
}

void rightt(int xx, int yy)
{
	Point p(xx, yy);
	int l = upper_bound(v.begin(), v.end(), Point(p)) - v.begin();
	int id = binr(l, n + 1, p);
	printf("%d\n", v[id].x);
}

int main()
{
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	scanf("%d %d", &n, &q);
	int kk = 0;
	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];
		kk = max(kk, abs(k[i]));
	}
	for (int i = 0; i <= n; i++)
		v.push_back(Point(x[i], y[i]));
	for (int i = 0; i < q; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		if (kk <= 1)
		{
			leftt(u, v);
			rightt(u, v);
		}
		else
		{
			left(u, v);
			right(u, v);
		}
	}
	return 0;
}