#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, q;
int seg[1 << 21];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n >> q;
  n = (1 << (32 - __builtin_clz(n)));
  for (int i = 0; i < q; i++) {
    int a, v;
    cin >> a >> v;
    a = a - 1 + n - 1;
    seg[a] += v;
    while (a > 0) {
      a = (a - 1) / 2;
      seg[a] = max(seg[2 * a + 1], seg[2 * a + 2]);
    }
    int p = 0;
    while (p < n - 1) {
      if (seg[2 * p + 1] >= seg[2 * p + 2]) p = 2 * p + 1;
      else p = 2 * p + 2;
    }
    cout << p - (n - 1) + 1 << " " << seg[0] << endl;
  }

  return 0;
}
