#include<iostream>
#include<queue>

using namespace std;
typedef pair<int,int> P;
int main(){
	int n,q; cin >> n >> q;
	int a[n];
	priority_queue<P> p;
	
	for(int k=0;k<n;k++){
		a[k] = 0;
	}

	int s,v;
	for(int i=0;i<q;i++){
		cin >> s >> v;
		a[s] += v;
		p.push(P(a[s],-s));

		for(;;){
			P t = p.top();
			if(t.first == a[-t.second]){
			cout << -1*t.second << " " << t.first << endl; break; }
			p.pop();
		}
	}
return 0;
}