#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

typedef pair < int, int > P;
priority_queue < P > que;

int data[1111111];

int solve(int a, int b){

  data[a] += b;
  que.push( P(data[a], -a) );

  for(;;){
    a = -que.top().S;
    b = que.top().F;

    if(b == data[a]) break;
    que.pop();
  }
  
  cout << a << " " << b << endl;
}

int main(){

  int n, q, a, b;
  cin >> n >> q;

  for(;q--;){
    cin >> a >> b;
    solve(a, b);
  }

}