#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int n, q;
	cin >> n >> q;
	vector<int> fish(n);
	int max_fish_people = 0;
	for(int i = 0; i < q; ++i)
	{
		int a, v;
		cin >> a >> v;
		--a;
		fish[a] += v;
		if(v < 0)
		{
			vector<int>::iterator it = max_element(fish.begin(), fish.end());
			max_fish_people = it - fish.begin();
		}
		if(fish[max_fish_people] < fish[a])
		{
			max_fish_people = a;
			cout << a + 1 << " " << fish[a] << endl;
		}
		else
		{
			cout << max_fish_people + 1 << " " << fish[max_fish_people] << endl;
		}
	}
}

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