#include <iostream>
#include <queue>
#include <utility>
using namespace std;

int main(){
  int n,q,a,v;
  int c[1000001]={0};
  typedef pair<int,int> P;
  priority_queue<P> s;
  cin>>n>>q;
  while(q--){
    cin>>a>>v;
    c[a]+=v;
    s.push(P(c[a],-a));
    while(1){
      P t=s.top();
      if(t.first==c[-t.second]){
	cout<<-t.second<<' '<<t.first<<endl;break;
      }
      s.pop();
    }
  }
  return 0;
}