#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

int n, q;
int fish[1000001];

int main() {
  cin >> n >> q;
  
  priority_queue<P> pq;
  
  for(int i = 0; i < q; i++) {
    int a, v;
    cin >> a >> v;
    fish[a] += v;
    pq.push(P(fish[a], a * (-1)));
    
    while(!pq.empty()) {
      P p = pq.top();
      p.second *= -1;
      if(p.first == fish[p.second]) {
        cout << p.second << ' ' << p.first << endl;
        break;
      }
      pq.pop();
    }
  }

  return 0;
}