#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;
void solve(){
	cout     << "\n";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int x[1000001] = {0};
	int n,q;
	cin >>n >> q;

	int max_now=0;
	int now_id = 1;


	for(int i=0;i<q;i++){
		int a ,v;
		cin >>a >> v;
		x[a-1] += v;

		if(v >0 && (x[a-1] > max_now || x[a-1]==max_now && now_id >a )){
			max_now = x[a-1];
			now_id = a;
		}else if(v<0 && now_id == a){
			max_now=0;
			now_id = 1;
			for(int j = 0;j<n;j++){
				if(x[j]>max_now){
					max_now=x[j];
					now_id = j+1;
				}
			}


		}
			cout << now_id <<" " << max_now << "\n";
	}

		
		
	/*
	while(cin >>){
	solve();	
	}
	*/
	return 0;
}