#include <iostream>
using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	int *r = new int[n + 1]();
	int ma = 1, mv = 0;

	int a, v;
	while (cin >> a >> v) {
		r[a] += v;
		int ra = r[a];
		if (a == ma) {
			if (v >= 0) {
				mv = ra;
			}
			else {
				mv = -101;
				for (int i = 1; i <= n; ++i) {
					if (r[i] > mv) {
						ma = i, mv = r[i];
					}
				}
			}
		}
		else {
			if (mv < ra) {
				ma = a, mv = ra;
			}
			else if (mv == ra && a < ma) {
				ma = a;
			}
		}
		cout << ma << " " << mv << endl;
	}
	delete[] r;

	return 0;
}