#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

#define reps(i,j,k) for(int i = j;i < k;i++)
#define rep(i,j) reps(i,0,j)
typedef pair < int,int > Pii;
int fish[1000001];
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	priority_queue < Pii > PQ;
	rep(i,q){
		int a,v;
		scanf("%d%d",&a,&v);
		fish[a] += v;
		PQ.push(Pii(fish[a],-a));
		while( !PQ.empty() ){
			Pii p = PQ.top();
			if(p.first == fish[-p.second]){
				printf("%d %d\n",-p.second,p.first);
				break;
			}
			PQ.pop();
		}
	}
	return 0;
}