#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>

using namespace std;

#define pii pair<int, int>
#define pdd pair<long double, long double>

const int N = 4e5;

struct line
{
	long long a, b, c;
};

pdd intersect(line a, line b)
{
	long double z = a.a * b.b - a.b * b.a;
	long long x = a.b * b.c - a.c * b.b;
	long long y = a.a * b.c - a.c * b.a;
	return pdd(x / z, -y / z);
}

//why would you do this to me...
//CH trick with segment tree.................

line lines[N];
long long posx[N];

bool operator < (line &a, line &b)
{
	return a.c < b.c;
}

int main()
{
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	int n, q;
	scanf("%d %d", &n, &q);
	long long x = 0, y = 0;
	for (int i = 0; i < n; ++i)
	{
		long long d, k;
		scanf("%I64d %I64d", &d, &k);
		lines[i].a = -k;
		lines[i].b = 1;
		lines[i].c = k * x - y;
		posx[i + 1] = x + d;
		y += k * d;
		x += d;
	}
	while (q--)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		auto it = lower_bound(posx, posx + n + 1, u) - posx;
		int posl = 0;
		if (it != 0)
		{
			posl = posx[it - 1];
			for (int i = it - 2; i >= 0; --i)
			{
				if (-lines[i].a * u - lines[i].c > v)
					break;
				else
					posl = posx[i];
			}
		}
		int posr = posx[n];
		if (it != n + 1)
		{
			posr = posx[it];
			for (int i = it; i < n; ++i)
			{
				if (-lines[i].a * u - lines[i].c > v)
					break;
				else
					posr = posx[i + 1];
			}
		}
		cout << posl << " " << posr << "\n";
	}
	return 0;
}