#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

long long int n[1000001];
priority_queue<long long int> p;

int main()
{
	memset(n,0,sizeof(n));

	int num,_q;
	cin >> num >> _q; 
		
	rep(i,_q)
	{
		int a,v;
		cin >> a >> v;
		
		n[a-1] += v;
		p.push(n[a-1]);
		
		long long int ans = p.top();

		vector<int> res;
		rep(j,1000001)
		{
			if(n[j] == ans)
			{
				res.push_back(j);
			}
		}
		sort(res.begin(),res.end());
		cout << res[0]+1 << " " << ans << endl;
	}
	return 0;
}