#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,q,a,v,ansnum=0,ansfish=-1;
	cin>>n>>q;
	int fish[n+1];
	rep(i,n+1){
		fish[i]=0;
	}
	fish[0]=-1000;
	rep(j,q){
		cin>>a>>v;
		fish[a]+=v;
		if(fish[ansnum]!=ansfish)ansfish=fish[ansnum];
		for(int i=n;i>=1;i--){
			if(ansfish<=fish[i]){
				ansnum=i;
				ansfish=fish[i];
			}
		}
		cout<<ansnum<<" "<<ansfish<<endl;
	}
	return 0;
}