#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> num(N + 1);
  priority_queue<pair<int,int>> que;
  for (int i = 0; i < Q; ++i) {
    int a, v;
    cin >> a >> v;
    num[a] += v;
    que.emplace(num[a], -a);
    while (num[-que.top().second] != que.top().first) que.pop();
    cout << -que.top().second << " " << que.top().first << endl;
  }
  return 0;
}