#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
bool pr(const int* p,const int* q){
  if(*p==*q)
    return p<q;
  else
    return *p>*q;
}
int main(){
  int i;
  int n,m;
  scanf("%d%d",&n,&m);
  int a[1000000]={};
  int* b[1000000];
  for(i=0;i<n;++i)
    b[i]=a+i;
  while(m--){
    int p,q;
    scanf("%d%d",&p,&q);
    --p;
    int** r=lower_bound(b,b+n,a+p,pr);
    int* s=*r;
    a[p]+=q;
    int** t=lower_bound(b,r,s,pr),** u=lower_bound(r+1,b+n,s,pr);
    if(false){
    }else if(t==r&&u==r+1){
    }else if(t==r){
      memmove(r,r+1,sizeof(int*)*(u-r-1));
      *(u-1)=s;
    }else if(u==r+1){
      memmove(t+1,t,sizeof(int*)*(r-t));
      *t=s;
    }
    printf("%d %d\n",b[0]-a+1,*b[0]);
  }
  return 0;
}