#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define mp make_pair
using namespace std;

struct ver
{
	int* a;
	int* b;
	int c;
};

typedef long long ll;

const int MAXN = 400010;
const int INF = 1000 * 1000 * 1000 + 2;
const int MRM = (1 << 20);
const int AS = 20 * 1000 * 1000;
int n, q;
int x[MAXN], y[MAXN];
int k[MAXN];
int qx[MAXN], qy[MAXN];
int ans[MAXN];
int a2[MAXN];
ver rmq[MRM];
int rb[MRM];
ll cr[MAXN];
int arr[AS], arrc = 0;
int id[MAXN];
int st[MAXN], sc = 0;
int bt[MAXN];
int iq[MAXN];

inline ll gy(int id, int xc)
{
	return (ll)(xc - x[id]) * k[id] + y[id];
}

int vx, vy, rv;

inline bool cmp(int id1, int id2)
{
	if (k[id1] < k[id2]) return true;
	if (k[id2] < k[id1]) return false;
	return cr[id1] < cr[id2];
}

bool alloc = true;

inline int* melloc(int x)
{
	arrc += x;
	return arr + (arrc - x);
}

inline void gver(int l, int r, ver& ans, ver* v1, ver* v2)
{
	if (alloc) ans.a = melloc(r - l + 1);
	if (alloc) ans.b = melloc(r - l + 1);
	ans.c = 0;
	if (l == r)
	{
		ans.a[0] = l, ans.b[0] = x[l];
		ans.c = 1;
		return;
	}
	int md = (l + r) / 2;
	for (int i = l; i <= r; i++)
	{
		cr[i] = gy(i, x[r]);
	}
	int p1 = 0, p2 = 0;
	sc = 0;
	while ((p1 < v1->c) || (p2 < v2->c))
	{
		int v;
		if ((p1 == v1->c) || ((p2 != v2->c) && (cmp(v2->a[p2], v1->a[p1])))) v = v2->a[p2++];
		else v = v1->a[p1++];
		int nbt;
		while (sc > 0)
		{
			ll dr = cr[st[sc - 1]] - cr[v];
			if (dr <= 0)
			{
				sc--;
				continue;
			}
			nbt = min((ll)INF, (dr + k[v] - k[st[sc - 1]] - 1) / (k[v] - k[st[sc - 1]]) + x[r]);
			if (bt[sc - 1] < nbt) break;
			sc--;
		}
		if (sc == 0) nbt = x[r];
		st[sc] = v;
		bt[sc++] = nbt;
	}
	for (int i = 0; i < sc; i++) ans.a[i] = st[i], ans.b[i] = bt[i];
	ans.c = sc;
	return;
}


void create_rmq(int v, int l, int r)
{
	rb[v] = 1;
	int md = (l + r) / 2;
	if (l != r)
	{
		create_rmq(v * 2 + 1, l, md);
		create_rmq(v * 2 + 2, md + 1, r);
		gver(l, r, rmq[v], rmq + v * 2 + 1, rmq + v * 2 + 2);
	}
	else gver(l, r, rmq[v], NULL, NULL);
}



int go_rmq(int v, int l, int r)
{
	int md = (l + r) / 2;
	while ((rb[v] < rmq[v].c) && (rmq[v].b[rb[v]] <= vx)) rb[v]++;
	if (l > rv) return -INF;
	if ((r <= rv) && (gy(rmq[v].a[rb[v] - 1], vx) <= vy)) return -INF;
	if (l == r) return x[l];
	int cur = go_rmq(v * 2 + 2, md + 1, r);
	if (cur == -INF) cur = go_rmq(v * 2 + 1, l, md);
	return cur;
}

bool cmpq(int i1, int i2)
{
	return qx[i1] < qx[i2];
}

void solve()
{
	for (int i = 1; i < n; i++) k[i] = (y[i] - y[i - 1]) / (x[i] - x[i - 1]);
	create_rmq(0, 1, n);
	for (int i = 0; i < q; i++) iq[i] = i;
	sort(iq, iq + q, cmpq);
	for (int i = 0; i < q; i++)
	{
		int v = iq[i];
		vx = qx[v], vy = qy[v];
		rv = lower_bound(x, x + n + 1, qx[v]) - x - 1;
		ans[v] = go_rmq(0, 1, n);
		if (ans[v] == -INF) ans[v] = x[0];
	}
}

int main()
{
	freopen("mountain.in", "r", stdin);
	freopen("mountain.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		int td, tk;
		cin >> td >> tk;
		x[i + 1] = x[i] + td;
		y[i + 1] = y[i] + td * tk;
	}
	for (int i = 0; i < q; i++)
		scanf("%d%d", &qx[i], &qy[i]);
	solve();
	for (int i = 0; i < q; i++) a2[i] = ans[i];
	for (int i = 0; i < q; i++) qx[i] = -qx[i];
	for (int i = 0; i <= n; i++) x[i] = -x[i];
	reverse(x, x + n + 1);
	reverse(y, y + n + 1);
	alloc = false;
	solve();
	for (int i = 0; i < q; i++)
	{
		cout << a2[i] << " " << -ans[i] << "\n";
	}
	return 0;
}