#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[100000] = {0};
  vector<int> ans;
  cin >> n >> q;
  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);
    ans.push_back((int)(prov- fish) + 1);
    ans.push_back(*prov);
  }

  for (int i = 0; i < q; i++)
    cout << ans[i * 2] << ' ' << ans[i * 2 + 1] << endl;
  return 0;
}