#include<iostream>
using namespace std;
int m(int *p,int n){
  int top = 1;
  for(int i=0;i<=n;i++){
    if(p[i]>p[top]) top = i;
  }
  return top;
}
int main(){
  int n,q,a,v;
  int max=0;
  cin >> n >> q;
  int p[n+1];
  for(int i=0;i<=n;i++) p[i] = 0;
  for(int i=0;i<q;i++){
    cin >> a >> v;
    p[a] += v;
    if(v>=0){
      if(p[max]<p[a]) max = a;
      if(p[max]==p[a]&&a<max) max = a;
    }else if(max==a) max = m(p,n);
    cout << max << ' ' << p[max] << endl;
  }
  return 0;
}