#include<iostream>
using namespace std;

int main(){

	int a, n, q, v, h;
	int w[1000001] = {0};
	
	cin >> n >> q;
	
	h = 0;
	for(int i=0; i<q; i++){
		cin >> a >> v;
		w[a] += v;
		if(a == h && v < 0){
			h = 0;
			for(int j=0; j<=n; j++){
				if(w[h] <= w[j]){
					if(w[h] != w[j] || h > j){
						h = j;
					}
				}
			}
		}
		else{
			if(w[h] <= w[a]){
				if(w[h] != w[a] || h > a){
					h = a;
				}
			}
		}
		
		cout << h << " " << w[h] << endl;
	}

	return 0;

}