#include <iostream>
#include <queue>
#include <string>
#include <string.h>
using namespace std;

typedef pair<int, int> P;
int fish[100000];
void q99() {
	int n, q;
	for (; cin >> n >> q;) {

		priority_queue<P > queue;
		memset(fish, 0, sizeof(fish));

		for (int i = 0; i < q; i++) {
			int a_i, v_i;
			cin >> a_i >> v_i;
			fish[a_i] += v_i;
			queue.push(make_pair(fish[a_i], -a_i));
			for (; !queue.empty();) {
				P top = queue.top();
				if (top.first == fish[-top.second]) {
					cout << -top.second << " " << top.first << endl;
					break;
				}
				queue.pop();
			}
		}
	}
}

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