#include<bits/stdc++.h>
using namespace std;
int n,q;
int a,v;
int tt[1000001]={0},ten[1000001]={0};
typedef pair<int,int> P;
priority_queue<P> qu;
int main(void)
{
	int i,j,flg,max,min,n1,nn,ten1;
	P ppp;
	
	cin>>n>>q;
	
	max=-1;
	min=1000000;
	flg=1000000;
	
	for(i=0;i<q;i++){
	
		cin>>a>>v;
		
		if(flg<a) flg=a;
		
		ten[a]+=v;
		
//		qu.push(P(ten[a],a));
		
/*		while(1){
			ppp=qu.top();
			nn=ppp.second;
			if(ten[nn]==ppp.first){
				max=ppp.first;
				min=nn;
				break;
			}
			qu.pop();
		}	*/
		
		max=-1;
		min=1000000;
		
		for(j=1;j<=n;j++){
			if(max<ten[j]){
				max=ten[j];
				min=j;
			}
		}
		
		cout<<min<<" "<<max<<endl;
		
/*		for(i=1;j<=n1;j++){
			if(max<ten[j]){
				max=ten[j];
				min=j;
			}
		}
		
		cout<<min<<" "<<max<<endl;
		*/
	}
	
	//cout<<min<<" "<<max<<endl;
	
	return 0;
	
}		
