#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>

using namespace std;

long long int seg[1000000 * 2];
int id[1000000 * 2];
void q99() {
	memset(seg, 0, sizeof(seg));
	memset(id, 0, sizeof(int) * 1000000);
	for (int i = 0; i < 1000000; i++) {
		id[1000000 + i] = i;
	}
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int a, v;
		cin >> a >> v;
		a += 1000000 - 1;
		seg[a] += v;
		while (a > 0) {
			a /= 2;
			if (seg[a * 2] < seg[a * 2 + 1]) {
				seg[a] = seg[a * 2 + 1];
				id[a] = id[a * 2 + 1];
			}
			else {
				seg[a] = seg[a * 2];
				id[a] = id[a * 2];
			}
		}
		cout << id[1]+1 << " " << seg[1] << endl;
	}
}
int main() {
	q99();
	return 0;
}