#include <iostream>
#include <queue>
using namespace std;

int ary[1000001];

int main()
{
	int n, q;
	priority_queue<pair<int, int>> que;

	cin >> n >> q;
	for (int i = 0; i < q; i++)
	{
		int a, b;
		cin >> a >> b;
		ary[a] += b;
		que.push(pair<int, int>(ary[a], -a));

		while (!que.empty())
		{
			pair<int, int> p = que.top();
			if (p.first == ary[-(p.second)])
			{
				cout << -(p.second) << ' ' << p.first << endl;
				break;
			}
			que.pop();
		}
	}

	return 0;
}