#include<iostream>
#include<sstream>
#include<string>

using namespace std;

int main()
{
	int n, num = 0, a[100000] = { 0 }, q, i, now;
	string str[10000];
	cin >> n >> q;
	for (i = 0; i < q; i++)
	{
		cin >> now >> n;
		a[now - 1] += n;
		if (a[now - 1] > a[num])
		{
			num = now - 1;
		}
		stringstream s;
		s << num + 1 << " " << a[num];
		str[i] = s.str();
	}
	for (i = 0; i < q; i++)
	{
		cout << str[i] << endl;
	}
    return 0;
}