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

using namespace std;

int main(){
  int n,q;
  cin>>n>>q;
  static int c[1000000];
  while(q--){
    int a,v;
    cin>>a>>v;
    c[a-1]+=v;
    int x=max_element(c,c+n)-c;
    cout<<x+1<<' '<<c[x]<<endl;
  }
  return 0;
}