#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forq(i, q, n) for (int i = int(q); i < int(n); ++i)
#define mk make_pair
#define psh push_back
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define Y second
#define X first
#define y1 asd
#define TASK "mountain"

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

const int MAXN = (int)1e6 + 7;
const int INF = (int)1e9 + 7;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;

void file()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	freopen(TASK".in", "r", stdin); freopen(TASK".out", "w", stdout);
#endif
}

struct ee {
	ll d, k;
};

vector <ee> B;
vector <pair <ll, ll> > A;

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

line pos(pair <ll, ll> a, pair <ll, ll> b) {
	pair <double, double> x1 = { a.X, a.Y }, x2 = { b.X, b.Y };
	return{ x2.Y - x1.Y, x1.X - x2.X, x2.X * x1.Y - x1.X * x2.Y };
}

pair <double, double> per(line a, line b) {
	return{(b.b * a.c - a.b * b.c) / (b.a * a.b - a.a * b.b), (b.a * a.c - a.a * b.c) / (a.a * b.b - b.a * a.b)};
}

bool check1(ll k, ll x, ll y) {
	ll ky;
	int x1, x2;
	forn(i, B.size()) {
		if (A[i + 1].X > k) {
			ky = A[i].Y + B[i].k * (k - A[i].X);
			x1 = i;
			x2 = i;
			break;
		}
		if (A[i + 1].X == k) {
			ky = A[i].Y + B[i].k * (k - A[i].X);
			x1 = i;
			x2 = i + 1;
			break;
		}
	}
	line b = pos(mk(k, ky), mk(x, y));
	forn(i, B.size()) {
		line a = pos(A[i], A[i + 1]);
		if (a.a * b.b == a.b * b.a) {
			continue;
		}
		pair <double, double> xpe = per(a, b);
		if (i != x1 && i != x2 && xpe.X > min(k, x) && xpe.X < max(k, x) && xpe.X > min(A[i].X, A[i + 1].X) && xpe.X < max(A[i].X, A[i + 1].X)) {
			return 0;
		}
	}
	return 1;
}

int main() {
	file();
	int n, q;
	ll d, k;
	scanf("%d%d", &n, &q);
	B.resize(n);
	A.resize(n + 1);
	A[0] = mk(0ll, 0ll);
	forn(i, n) {
		scanf("%lld%lld", &B[i].d, &B[i].k);
		A[i + 1] = mk(A[i].X + B[i].d, A[i].Y + B[i].k * B[i].d);
	}
	ll x, y;
	forn(i, q) {
		scanf("%lld%lld", &x, &y);
		ll l = x;
		for (; l >= 0; --l) {
			if (!check1(l, x, y)) {
				break;
			}
		}
		++l;
		printf("%lld ", l);
		l = x;
		for (; l <= A[n].X; ++l) {
			if (!check1(l, x, y)) {
				break;
			}
		}
		--l;
		printf("%lld\n", l);
	}
	return 0;
}
