#include<cstdio>
#include<algorithm>

using namespace std;

int n,q;
int a[100001],v[100001];
int val[1<<22],mid[1<<22];

void update(int a,int x){
	a+=(1<<21);
	val[a]+=x;
	while(a>0){
		a=(a-1)/2;
		val[a]=max(val[a*2+1],val[a*2+2]);
		if(val[a]==val[a*2+1])mid[a]=mid[a*2+1];
		else mid[a]=mid[a*2+2];
	}
}

int main(void){
	scanf("%d%d",&n,&q);
	for(int i=1<<21;i<(1<<22);i++)mid[i]=i-(1<<21);
	for(int i=0;i<q;i++){
		scanf("%d%d",&a[i],&v[i]);
		update(a[i]-1,v[i]);
		printf("%d %d\n",mid[0]+1,val[0]);
	}
	return 0;
}