#include<iostream>
#include<algorithm>
using namespace std;
typedef long long lint;
int main(){
	lint n, q; cin >> n >> q;
	lint l[100010] = { 0 };
	for (lint i = 0; i < q; i++){
		lint a, b; cin >> a >> b;
		l[a] += b;
		lint num = 0;
		lint maxs = 0;
		for (lint i = 1; i < n + 1; i++) {
			if (maxs < l[i]) { 
				num = i;
				maxs = l[i];
			}
			else if (maxs == l[i])num = min(num, i);
		}
		cout << num << ' ' << l[num] << endl;
	}
}