#include <iostream>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cassert>
#include <ctime>
#include <cstring>
#include <string>

using namespace std;

#define int long long

bool comp(int k, int dx, int dy) {
	/*int q1 = k >= 0;
	int q2 = (dy > 0 || dy == 0 && dx >= 0);
	if (q1 != q2)
		return q1 < q2;*/
	return k * dx <= dy;
}

bool eq(int k, int dx, int dy) {
	/*int q1 = k >= 0;
	int q2 = (dy > 0 || dy == 0 && dx >= 0);
	if (q1 != q2)
	return q1 < q2;*/
	return k * dx == dy;
}


signed main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	int n, q;
	cin >> n >> q;
	vector<int> k(n), in_l(n), h{ 0 };
	for (int i = 0; i < n; i++) {
		cin >> in_l[i] >> k[i];
		h.push_back(h.size() ? h.back() + in_l[i] * k[i] : in_l[i] * k[i]);
	}
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		int cx = 0;
		int ind = 0;
		while (cx < x && ind < n)
			cx += in_l[ind], ind++;
		int r = min(ind, n - 1), l = min(ind, n - 1), rx = cx, lx = cx;
		while (l >= 0 && comp(k[l], x - lx, y - h[l])) {
			if (l > 0)
				lx -= in_l[--l];
			else
				l--;
		}
		if (l >= 0)
			lx += in_l[l++];
		else
			l++;
		while (r < n && comp(k[r], x - rx, y - h[r])) {
			rx += in_l[r++];
		}
		//rx -= in_l[--r];
		cout << lx << ' ' << rx << endl;
	}
    return 0;
}

