#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long lng;
typedef long double ldbl;

int n, q;
struct line
{
	lng  k;
	ldbl x;
	lng x1, y1, x2, y2;
};

line lft[500000], rght[500000], horiz[500000];
int nl, nr, nh;

int main()
{
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	scanf("%d%d", &n, &q);
	lng curx = 0, cury = 0, ncurx, ncury;
	for (int i = 0; i < n; ++i)
	{
		int d, k; scanf("%d%d", &d, &k);
		ncurx = curx + lng(d);
		ncury = cury + lng(d) * lng(k);
		line temp = { k, ldbl(ldbl(curx) - ldbl(cury) / ldbl(k)), curx, cury, ncurx, ncury };
		if (k > 0)
			lft[nl++] = temp;
		else if (k < 0)
			rght[nr++] = temp;
		else
			horiz[nh++] = temp;
		curx = ncurx;
		cury = ncury;
	}
	for (int i = 0; i < q; ++i)
	{
		lng ansleft = 0;
		lng ansright = curx;
		int x, y; scanf("%d%d", &x, &y);
		for (int j = 0; j < nl; ++j)
		{
			lng yy = lft[j].y1 + (lng(x) - lft[j].x1) * lft[j].k;
			if (yy > y)
				ansleft = max(ansleft, lft[j].x2);
		}
		for (int j = 0; j < nr; ++j)
		{
			lng yy = rght[j].y1 + (lng(x) - rght[j].x1) * rght[j].k;
			if (yy > y)
			{
				ansright = min(ansright, rght[j].x1);
			}
		}
		for (int j = 0; j < nh; ++j)
		{
			if (horiz[j].y1 > y)
			{
				if (horiz[j].x2 < x)
					ansleft = max(ansleft, horiz[j].x2);
				else if (horiz[j].x1 > x)
					ansright = min(ansright, horiz[j].x1);
			}
		}
		printf("%lld %lld\n", ansleft, ansright);
	}
	return 0;
}