#include<iostream>
#include<algorithm>
using namespace std;

// Time Limit Error ??????????????????
int main(){
  int n,q;

  
  cin>>n>>q;

  
  vector< int > A ( n , 0 );// ??????n,?????????0??????????????¨???
  
  for(int i=0;i<q;i++){
    int a,v;
    cin>>a>>v;
    A[a-1]+=v;

    int maxm=0;
    for(int j=1;j<n;j++){
      if( A[j] > A[maxm] ){
        maxm=j;
      }
    }

    cout<<maxm+1<<' '<<A[maxm]<<endl;
  }
  return 0;
}