#include<stdio.h>
#include<iostream>
using namespace std;
int n[1000001]={};
int main(){

	int N,Q;
	cin>>N>>Q;
	
	for(int i=0;i<Q;i++){
		int x,y;
		cin>>x>>y;
		n[x]+=y;
		int max=0;int id=0;
		for(int j=1;j<=N;j++)
			if(max<n[j]){max=n[j];id=j;}

		cout<<id<<" "<<max<<endl;
	}
	return 0;
}