#include<iostream>
using namespace std;
int main(){
long n,q,a,*v,vv,x,xx,i,j;
cin>>n>>q;
v=new long[n+1];
for(j=1;j<=n;j++)v[j]=0;
for(i=0;i<q;i++){
cin>>a>>vv;
v[a]+=vv;
x=-1;
for(j=1;j<=n;j++){
if(x<v[j]){x=v[j];xx=j;}
}
cout<<xx<<" "<<x<<endl;
}
return 0;
}