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

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

void init() {
  int _n = n;
  n = 1;
  while (n < _n) n <<= 1;
}

void add(int a, int v) {
  a += n - 1;
  seg[a] += v;
  while (a) {
    a = (a - 1) / 2;
    seg[a] = max(seg[2 * a + 1], seg[2 * a + 2]);
  }
}

int idx() {
  int v = seg[0];
  int k = 0;
  while (k < n - 1) {
    int l = 2 * k + 1;
    int r = 2 * k + 2;
    if (seg[l] == v) k = l;
    else k = r;
  }

  return k - n + 2;
}

void solver(int a, int v) {
  add(--a, v);
  cout << idx() << " " << seg[0] << endl;
}

int main() {
  cin >> n >> q;
  init();

  while (q--) {
    int a, v;
    cin >> a >> v;
    solver(a, v);
  }
}