#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
pair<int,int> tree[1000000*2-1];
int n,q;
void update(int a,int v){
  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;
    }
}

int main(){

 cin>>n>>q;
    {
      memset(tree,0,sizeof(tree));
      for(int i=0;i<q;i++)
	{
	  int a,v;
	  cin>>a>>v;
	  a--;
	  update(a,v);
	  cout<<tree[0].second<<" "<<tree[0].first<<endl;
	  //	  output();
	}
    }
}