#include<algorithm>
#include<iostream>
#include<vector>
using namespace  std;
int compare1(const void *a, const void *b)
{
	pair<int, int> aa = *(pair<int, int>*)a;
	pair<int, int> bb = *(pair<int, int>*)b;
	if (aa.second > bb.second)return -1;
	if (aa.second == bb.second && aa.first < bb.first)return -1;
	return 1;
}
int compare2(const void *a, const void *b)
{
	pair<int, int> aa = *(pair<int, int>*)a;
	pair<int, int> bb = *(pair<int, int>*)b;
	return aa.first - bb.first;
}
bool sort_func(pair<int,int> a,pair<int,int> b)
{
	if (a.second > b.second)return true;
	if (a.second == b.second && a.first < b.first)return true;
	return false;
}
int main()
{
	pair<int, int> e[100000];
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		e[i].first = i + 1;
		e[i].second = 0;
	}
	int a, v;
	for (int i = 0; i < q; i++)
	{
		cin >> a >> v;
		e[a - 1].second += v;
		//sort(e, e + 100000, sort_func);
		qsort(e, n, sizeof(pair<int,int>),compare1);
		cout << e[0].first << " " << e[0].second<<endl;
		qsort(e, n, sizeof(pair<int, int>), compare2);
		//sort(e, e + 100000);
	}
	return 0;
}