#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
  int n,q,a,b; 
  int v[1000000];
  int f = 0;
  while(cin >> n >> q){
    if(f)cout << endl;
    fill(v,v+n,0);
    for(int i = 0 ; i < q ; i++){
      cin >> a >> b;
      v[a-1] += b;
      int max = 0,ret;
      for(int j = 0 ; j < n ; j++){
	if(max < v[j]){
	  max = v[j];
	  ret = j+1;
	}
      }
      cout << ret <<" "<< max <<  endl;
    }
    f = 1;
  }
  return 0;
}