
int main(){
	int q,num,v,max,maxnum;
	
	
	maxnum = 0;
	cin >> n >> q;
	int wakasagi[10000];
	max = wakasagi[0];
	maxnum=0;
	for(int i=0;i<q;i++){
		 cin >> num >> v;
		 wakasagi[num] += v;
		 
		 if(v < 0){
			if(num == maxnum){
				wsearch(&max,&maxnum,wakasagi);
			}
		 } else if(v > 0){
			if(num != maxnum){
				wsearch(&max,&maxnum,wakasagi);
			}
		 }
		 
		 cout << maxnum << " " << max<< endl;
	}
	
	
}