#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <cmath>

#pragma comment(linker, "/STACK:256000000")

using namespace std;

typedef long long int ll;
typedef long double ld;
const int MAX_N = 400 * 1000 + 5;

struct point
{
	ll x;
	ll y;

	point()
	{
		x = 0;
		y = 0;
	}

	point(ll _x, ll _y)
	{
		x = _x;
		y = _y;
	}
};

bool operator< (const point &a, const point &b)
{
	return a.x < b.x;
}

point operator+ (const point &a, const point &b)
{
	return point(a.x + b.x, a.y + b.y);
}

point operator- (const point &a, const point &b)
{
	return point(a.x - b.x, a.y - b.y);
}

ll operator* (const point &a, const point &b)
{
	return a.x*b.y - a.y*b.x;
}

ll operator% (const point &a, const point &b)
{
	return a.x*b.x + a.y*b.y;
}

int n, q;
point arr[MAX_N];

void get_ans(point p)
{
	int ptr = upper_bound(arr, arr + n, p) - arr;
	
	int l = ptr - 1;
	int r = ptr;

	if (arr[r].x == p.x)
	{
		++r;
	}

	point p1, p2;
	while (r < n - 1)
	{
		p1 = arr[r] - p;
		p2 = arr[r + 1] - p;
		if (p1*p2 < 0)
		{
			break;
		}
		++r;
	}
	while (l > 0)
	{
		p1 = arr[l] - p;
		p2 = arr[l - 1] - p;
		if (p1*p2 > 0)
		{
			break;
		}
		--l;
	}
	//cout << l << " " << r << endl;
	printf("%lld %lld\n", arr[max(l, 0)].x, arr[min(r, n - 1)].x);
}

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

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

	ll d, k;
	arr[0].x = 0;
	arr[0].y = 0;

	for (int i = 0; i < n; ++i)
	{
		scanf("%lld %lld", &d, &k);
		arr[i + 1].x = arr[i].x + d;
		arr[i + 1].y = arr[i].y + d*k;
	}

	++n;


	point now;
	for (int i = 0; i < q; ++i)
	{
		scanf("%lld %lld", &now.x, &now.y);
		get_ans(now);
	}

	fclose(stdin);
	fclose(stdout);

	return 0;
}