#include<bits/stdc++.h>
using namespace std;

int  main()
{
  int a,b;
  cin>>a>>b;
  b+=a*0;
  map<int,int>s;
  for(int c=0;c<b;c++){
	  int d,e;
	  cin>>d>>e;
	  s[d];
	  s[d]+=e;
	   map<int,int>n;
	   for(auto f=s.begin();f!=s.end();f++){
		   n.insert(pair<int,int>(f->second,f->first));
		   }
		   auto y=n.end();
		   y--;
		   cout<<y->second<<" "<<y->first<<endl;
	  }	
}