#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

struct Data{
	int n,p;
	Data(int _n,int _p){
		n=_n; p=_p;
	}
	bool operator<(const Data &a)const{
		if(p==a.p) return n>a.n;
		return p<a.p;
	}
};

int cnt[1000000];

int main(){
	priority_queue<Data> pq;
	int N,Q,A,V;
	cin>>N>>Q;
	for(int i=0;i<N;i++) pq.push(Data(i,0));
	for(int i=0;i<Q;i++){
		cin>>A>>V; A--;
		cnt[A] += V;
		pq.push(Data(A,cnt[A]));
		while(cnt[pq.top().n]!=pq.top().p) pq.pop();
		printf("%d %d\n",pq.top().n+1,pq.top().p);
	}
	return 0;
}