#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long lint;
int main(){
	lint n, q; cin >> n >> q;
	lint l[1000010] = { 0 };
	vector<lint>v;
	for (lint i = 0; i < q; i++){
		lint a, b; cin >> a >> b;
		if (find(v.begin(), v.end(), a) == v.end())v.push_back(a);
		l[a] += b;
		l[a] = max((lint)0, l[a]);
		lint num = 0, maxs = 0;
		sort(v.begin(), v.end());
		for (lint i = 0; i < v.size(); i++) {
			if (maxs < l[v[i]]) { 
				num = v[i];
				maxs = l[v[i]];
			}
		}
		cout << num << ' ' << l[num] << endl;
	}
}