#include <iostream>
#include <cstdio>
#include <utility>
#include <queue>
using namespace std;
typedef pair<int,int> P;

int A[1000001]={0};
int main(){
  int n,q,a,b; 
  int f = 0;
  cin >> n >> q;
  priority_queue<P> pp;
  pp.push(P(0,-1));

    for(int i = 0 ; i < q ; i++){
      cin >> a >> b;
      A[a] += b;
      pp.push(P(A[a],-a));
      while(1){
      int x = -pp.top().second;
      int y = pp.top().first;
      if(A[x] == y){
	cout << x << " " << y << endl;
      break;
      }
      pp.pop();
      }

    }
  return 0;
}