#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int n, q;
  long long *fish, *tmp;
  cin >> n >> q;
  fish = new long long[n];
  memset(fish, 0, sizeof(long long) * n);
  for (int i = 0; i < q; i++) {
    int a, v;
    long long *prov;
    cin >> a >> v;
    fish[a - 1] += v;
    prov = max_element(fish, fish + n);
    cout << (int)(prov- fish) + 1  << ' ' << *prov << endl;
  }
  return 0;
}