#include<iostream>
using namespace std;
int main(){
  int n,q,N,Q,a,v;
  int tn[1000001],tq[1000001];
  for(int i=0;i<1000001;i++){tn[i]=i;tq[i]=0;}
  cin>>n>>q;
  N=1;Q=0;
  for(int i=0;i<q;i++){
    cin>>a>>v;
    tq[a]+=v;
    if(Q<tq[a]){
      N=a;
      Q=tq[a];
    }else if(Q==tq[a]&&a<N){
      N=a;
      Q=tq[a];
    }
    cout<<N<<' '<<Q<<endl;
  }
  return 0;
}