#include<iostream>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
typedef pair<int, int>P;
priority_queue<P>Q;
int a[1141919];

int main() {
	int n, q;
	cin >> n >> q;

	for (int i = 0; i < q; i++) {
		int f, g;
		cin >> f >> g;
		a[f] += g;
		Q.push(P(a[f], f*-1));
		while (Q.size()) {
			if (Q.top().first == a[-Q.top().second]) {
				cout << - Q.top().second << ' ' << Q.top().first << endl;
				break;
			}
			Q.pop();
		}
	}
	return 0;
}