#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void){

  int n,q,p[1000001],a,v;
  fill(p,p+1000001,0);

  cin >> n >> q;

  while(q--){
    cin >> a >> v;
    p[a]+=v;
    int m=0;
    for(int i=1;i<=n;i++)m=max(m,p[i]);
    for(int i=1;i<=n;i++){
      if(p[i]==m){
	cout << i <<" "<< p[i] << endl;
	break;
      }
    }

  }
  return 0;
}