//55
#include<iostream>
#include<algorithm>

using namespace std;

const int N=1000000;
const int B=N-1;
int c[N];
int pa[N*2];

void rec(int x){
  if(x==0)return;
  int p=(x-1)/2;
  pa[p]=(c[pa[p*2+1]]>=c[pa[p*2+2]])?pa[p*2+1]:pa[p*2+2];
  rec(p);
}

int main(){
  int n,q;
  cin>>n>>q;
  for(int i=0;i<B;i++){
    pa[B]=N*2-1;
  }
  for(int i=0;i<N;i++){
    pa[B+i]=i;
  }
  while(q--){
    int a,v;
    cin>>a>>v;
    c[a-1]+=v;
    rec(B+a-1);
    cout<<pa[0]+1<<' '<<c[pa[0]]<<endl;
  }
  return 0;
}