#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;

int fish[1000001] = { 0 };
typedef pair<int, int> Pii;

void AOJ0099() {
	int n, q;
	int a, v;
	cin >> n >> q;

	priority_queue<Pii> pq;

	for (int i = 0; i < q; i++) {
		cin >> a >> v;
		fish[a] += v;
		pq.push(Pii(fish[a], -a));

		Pii p;
		while (!pq.empty()) {
			p = pq.top();
			if (p.first == fish[-p.second]) {
				break;
			}
			pq.pop();
		}
		printf("%d %d\n", -p.second, p.first);
	}
	return;
}

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