#include<iostream>
using namespace std;

int main(){

  int n,q;
  int z[1000001] = {0};
  int a,b;
  int k,ans;

  cin >> n >> q;

  for(int i=0;i<q;i++){
    cin >> a >> b;
    z[a] += b;
    ans = -1;
    k = -1;
    for(int i=1;i<=n;i++){
      if(ans < z[i]){
	ans = z[i];
	k = i;
      }
    }

    cout << k << " " <<  ans << endl;
  }

}