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


int main(){
  int n,q;
  for(;cin>>n>>q;)
    {
      pair<int,int> tree[n*4-1];
      for(int i=0;i<n*4-1;i++)
	tree[i]=make_pair(0,0);
      //tmemset(tree,0,sizeof(tree));
      for(int i=0;i<q;i++)
	{
	  int a,v;
	  cin>>a>>v;
	  a--;
	  int num=((n*2-1)-(n-1))+a;
	  tree[num].first+=v;
	  tree[num].second=a+1;
	  pair<int,int> base;
	  while(true)
	    {
	      num=(num-1)/2;
	      if(tree[num*2+1].first<tree[num*2+2].first)
		base=tree[num*2+2];
	      else
		base=tree[num*2+1];
	      tree[num]=base;
	      if(num==0)
		break;
	    }
	  cout<<tree[0].second<<" "<<tree[0].first<<endl;
	  //	  output();
	}
    }
}