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