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

int main(){
  int n, q;
  cin>>n>>q;
  vector<int> A(n,0);
  priority_queue< pair<int,int> > Q;
  for(int i=0;i<n;i++){
    Q.push( make_pair(0, -i) );
  }

  for(int i=0;i<q;i++){
    int a, v;
    cin>>a>>v;
    a--;
    A[a]+=v;
    Q.push( make_pair ( A[a], -a) );

    pair<int,int> ans;
    while(i){
      ans=Q.top();
      if(ans.first==A[-ans.second]){
	cout<<-ans.second+1<<" "<<ans.first<<endl;
	break;
      }else{
	Q.pop();
      }
    }
  }

  return 0;
}