#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int MAX_N = 1 << 20;
const int INF = (int)1e9;
pair<int, int> V[2*MAX_N - 1];
void add(int a, int v) {
  a += MAX_N - 1; // move to leaf
  V[a].first += v;
  while(a > 0) {
    a = (a - 1) / 2;
    V[a] = max(V[2*a + 1], V[2*a + 2]);
  }
}
pair<int, int> getMax() {
  return V[0];
}

int main() {
  int N, Q; cin >> N >> Q;
  for(int i = 0; i < 2*MAX_N - 1; ++i) {
    V[i] = make_pair(0, -INF);
  }
  for(int i = 0; i < N; ++i) {
    V[i + MAX_N - 1].second = -i;
  }
  while(Q--) {
    int a, v; cin >> a >> v;
    --a;
    add(a, v);
    pair<int, int> p = getMax();
    cout << -p.second + 1 << ' ' << p.first << endl;
  }
}