#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
priority_queue<P>Q;
int a[1141919];

int main(){
	int n,q;
	cin>>n>>q;
	
	for(int i=0;i<q;i++){
		int f,g;
		cin>>f>>g;
		a[f-1]+=g;
		Q.push(P(a[f-1],f*-1));
		cout<<-1*Q.top().second<<' '<<Q.top().first<<endl;
		}
		return 0;
	}