#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<ll,ll> P;
static const int INF=1<<24;

ll n,q;
bool f[1000010];
vector <int> ve;
map<ll,ll> ma;
pair<ll,ll> MAX;

bool cmpcount(P T1,P T2){
	return T1.S < T2.S;
}


int main(){
	cin>>n>>q;
	ll a,v;
	MAX.S=-1;
	rep(i,q){
		cin>>a>>v;
		if(!f[a]){
			ve.PB(a);
			f[a]=true;
		}
		ma[a]+=v;
		if(ma[a]>MAX.S||(ma[a]==MAX.S&&MAX.F>a)||(v>=0&&MAX.F==a)){
			MAX.F=a;
			MAX.S=ma[a];
			//cout<<"A ";
		}
		else if(v<0&&MAX.F==a){
			MAX.F=ve[0]; MAX.S=ma[ve[0]];
			//cout<<"else\n";
			MAX= *max_element(ma.begin(),ma.end(),cmpcount);
			/*
			rep(j,ve.size()){
				//cout<<"ma[ve[i]] ve[i]"<<ma[ve[j]]<<" "<<ve[j]<<endl;
				
				if(ma[ve[j]]>MAX.S||(ma[ve[j]]==MAX.S&&MAX.F>ve[j])){
					MAX.F=ve[j]; MAX.S=ma[ve[j]];
				}
				
			}
			*/
		}
		else{
			//cout<<"else\n";
			rep(j,ve.size()){
				//cout<<"ma[ve[i]] ve[i]"<<ma[ve[j]]<<" "<<ve[j]<<endl;
				if(ma[ve[j]]>MAX.S||(ma[ve[j]]==MAX.S&&MAX.F>ve[j])){
					MAX.F=ve[j]; MAX.S=ma[ve[j]];
					break;
				}
			}
			//MAX= *max_element(ma.begin(),ma.end(),cmpcount);
		}
		cout<<MAX.F<<" "<<MAX.S<<endl;
	}
	return 0;
}