#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,q;
	cin>>n>>q;
	vector<int>in(n);
	int to=0;
	rep(i,q){
		int a,b;cin>>a>>b;
		a--;
		in[a]+=b;
		if(to==a){
			if(b<0){
				int ma=-1e9,mai;
				rep(j,n)if(ma<in[j]){ma=in[j];mai=j;}
				to=mai;
			}
		}else{
			if(b>0&&in[to]<in[a])to=a;
		}
		cout<<to+1<<" "<<in[to]<<endl;
	}
}