#include <queue>
#include <cstdio>

#pragma warning(disable : 4996)

using namespace std;

int n, q, c[1000000], a, v;

int main()
{
	scanf("%d", &n);
	scanf("%d", &q);

	priority_queue<pair<int, int> > que;

	for (int i = 0; i < q; i++)
	{
		scanf("%d", &a);
		scanf("%d", &v);

		c[a - 1] += v; que.push(make_pair(c[a - 1], -a));

		while (que.top().second + 1 == -a) que.pop();

		pair<int, int> maximum = que.top();

		printf("%d %d\n", -maximum.second, maximum.first);
	}

	return 0;
}