#include <iostream>
#include <set>
using namespace std;

typedef pair<int, int> P;
struct wksg {
  bool operator() (const P &l, const P &r) const {
    if (l.second > r.second) {
      return true;
    } else if (l.second < r.second) {
      return false;
    } else if (l.first < r.first) {
      return true;
    } else {
      return false;
    }
  }
};

typedef set<P, wksg> M;

int vv[1000001];
M m;

int main() {
  int n, q, a, v, b;
  M::iterator it;

  cin >> n >> q;
  for (int i=0; i<n; i++) vv[i] = 0;
  for (int i=0; i<q; i++) {
    cin >> a >> v;
    it = m.find(P(a,vv[a]));
    if (it != m.end()) {
      m.erase(it);
    }
    vv[a] += v;
    m.insert(P(a,vv[a]));
    it = m.begin();
    cout << it->first << " " << it->second << endl;
  }

  return 0;
}