#include <cstdio>
#include <algorithm>

using namespace std;

pair<int, int> seg[1 << 18];

void add(int k, int x)
{
	k += (1 << 17) - 1;
	seg[k].first = k - (1 << 17) + 1;
	seg[k].second += x;
	
	while (k){
		k = (k - 1) >> 1;
		if (seg[k * 2 + 2].second > seg[k * 2 + 1].second){
			seg[k] = seg[k * 2 + 2];
		}
		else {
			seg[k] = seg[k * 2 + 1];
		}
	}
}

pair<int, int> getMax(int a, int b, int k = 0, int l = 0, int r = 1 << 17)
{
	if (b <= l || r <= a) return (make_pair(-1, -1));
	
	if (a <= l && r <= b) return (seg[k]);
	
	pair<int, int> lch = getMax(a, b, k * 2 + 1, l, (l + r) / 2),
					rch = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
	
	if (rch.second > lch.second) return (rch);
	return (lch);
}

int main()
{
	int n, q;
	
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; i++) add(i, 0);
	
	for (int i = 0; i < q; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		add(a - 1, b);
		
		pair<int, int> x = getMax(0, n);
		
		printf("%d %d\n", x.first + 1, x.second);
	}
	
	return (0);
}