#include<iostream>
using namespace std;

int main(){
	int n,q,num,v,max,maxnum;
	int wakasagi[1000000];
	
	cin >> n >> q;
	for(int i=0;i<q;i++){
		 cin >> num >> v;
		 wakasagi[num] += v;
		 max = wakasagi[0];
		 maxnum = 0;
		 for(int k=1;k<=n;k++){
			if(max < wakasagi[k]){
				max = wakasagi[k];
				maxnum = k;
			}
		 }
		 cout << maxnum << " " << max<< endl;
	}
}