#include<iostream>
using namespace std;
int a[1145141];
int main() {
	int n, q; cin >> n >> q;
	for (int i = 1; i <= n; i++)a[i] = 0;
	int p = 0, num = 0;
	for (int j = 0; j < q; j++){
		int b, c; cin >> b >> c;
		a[b] += c;
		if (c > 0) {
			if (num < a[b]) { p = b; num = a[b]; }
			else if (num == a[b] && p > b)p = b;
		}
		else if (b == p) {
			for (int i = 1; i <= n; i++) {
				if (a[b] < a[i]) {
					p = i; num = a[i];
				}
			}
		}
		cout << p << ' ' << num << endl;
	}
}