#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
set<pair<int, int>>s;
int a[1234567];
signed main() {
	int n, q; cin >> n >> q;
	for1(i, n)s.insert(mp(0, n - i));
	for1(valsqotch, q) {
		int id, v; cin >> id >> v;
		s.erase(s.find(mp(a[id], n - id)));
		a[id] += v;
		s.insert(mp(a[id], n - id));
		auto itr = s.end(); itr--;
		cout << n - (*itr).second << ' ' << (*itr).first << endl;
	}
}
