#include<cstdio>
#include<iostream>
#include<utility>

#define NMAX 1000000

using namespace std;

int main(void){

	int n,q;
	int a,v;
	int inc[NMAX];
	int max_i;

	cin>>n>>q;
	for(int i=0;i<=n;i++){
		inc[i]=0;
	}

	for(int i=0;i<q;i++){
		cin>>a>>v;
		inc[a]+=v;
		max_i=0;
		for(int i=1;i<=n;i++){
			if(inc[max_i]<inc[i]) max_i=i;
		}
		cout<<max_i<<" "<<inc[max_i]<<endl;
	}

	return 0;
}