#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#define min(a,b) {a > b ? b:a}
using namespace std;

long long int seg[1000000 * 2];
int id[1000000 * 2];

void q99() {
	int n, q;
	cin >> n >> q;

	for (int i = 0; i < N; i++) {
		id[i + N] = i;
	}
	for (int i = 0; i < q; i++) {
		int a, v;
		cin >> a >> v;
		segment[N + a - 1] += v;
		for (int j = (N + a - 1) >> 1; j > 0; j = j >> 1) {
			if (segment[j * 2] == segment[j * 2 + 1]) {
				segment[j] = segment[j * 2];
				id[j] = min(id[j * 2], id[j * 2 + 1]);
			}
			else if (segment[j * 2] > segment[j * 2 + 1]) {
				segment[j] = segment[j * 2];
				id[j] = id[j * 2];
			}
			else {
				segment[j] = segment[j * 2 + 1];
				id[j] = id[j * 2 + 1];
			}
		}
		cout << id[1] + 1 << " " << segment[1] << endl;
	}

}
int main() {
	q99();
	return 0;
}