#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;
  cin>>n>>m;
  int a[1000000]={};
  vector<int*> b(n);
  for(i=0;i<n;++i)
    b[i]=a+i;
  while(m--){
    int p,q;
    cin>>p>>q;
    --p;
    int r=lower_bound(b.begin(),b.end(),a+p,pr)-b.begin();
    int* s=b[r];
    a[p]+=q;
    b.erase(b.begin()+r);
    b.insert(lower_bound(b.begin(),b.end(),s,pr),s);
    cout<<b[0]-a+1<<' '<<*b[0]<<endl;
  }
  return 0;
}