#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;
int main(){
	long n,q; cin >> n >> q;
	int MAX_N=0; long MAX_POW=1;
	while(n>MAX_POW) MAX_N++,MAX_POW*=2;
	long a[210000]={0}; long num[210000];
	memset(num,-1,sizeof(num));// memset(a,0,sizeof(a));
	long MAX_POW_tmp=MAX_POW;
	for(long i=0;i<q;i++){
		long tmp,TMP; cin >> tmp >> TMP;
		tmp--; //tmpはinputでは1base、処理は0base
		a[tmp]+=TMP; num[tmp]=tmp; long acc=0; MAX_POW=MAX_POW_tmp;
		long next_N=tmp/2;
		//以下seg tree
		for(int j=1;j<=MAX_N;j++){
			if(a[acc+next_N*2]>=a[acc+next_N*2+1]) a[acc+next_N+MAX_POW]=a[acc+next_N*2], num[acc+next_N+MAX_POW]=num[acc+next_N*2];
			else a[acc+next_N+MAX_POW]=a[acc+next_N*2+1],num[acc+next_N+MAX_POW]=num[acc+next_N*2+1];
			acc+=MAX_POW; MAX_POW/=2; next_N/=2;
		}
		//以上seg tree
		cout << num[acc]+1 << ' ' << a[acc] << '\n';
	//	for(int j=0;j<=2*n;j++) cerr << a[j] << ' ' ; cerr << '\n' ;
	}
}