#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

struct angler{
	int ID;
	int num;
	
	angler(){
		ID = 0;
		num = 0;
	}
	
	angler(int id, int NUM){
		if(id <= 0){
			id = (1 << 30);
		}else{
			ID = id;
		}
		num = NUM;
	}
};

int const MAX_TREE_SIZE = 1 << 21;
angler max_tree[MAX_TREE_SIZE];

angler max_a(angler p1, angler p2){
	if(p1.num > p2.num){
		return p1;
	}else if(p1.num < p2.num){
		return p2;
	}else{
		if(p1.ID < p2.ID){
			return p1;
		}
	}
	return p2;
}

void add(int a, int w){
	
	// a?????????????´????w????¶???? O(log N)
	
	a += (1 << 20);
	
	max_tree[a].num += w;
	
	for(int x = a / 2; x > 0; x /= 2){
		max_tree[x] = max_a(max_tree[2 * x], max_tree[2 * x + 1]);
	}
}

angler max_person(int a){
	
	// MAX_SIZE_TREE?????§???????´?????????§???????????? O(1)
	
	return max_tree[1];
}

int main(){
	
	int N, q;
	
	cin >> N >> q;
	
	for(int i = 0; i < (MAX_TREE_SIZE); i++){
		max_tree[i] = angler(i - (1 << 20), 0);
	}
	
	for(int i = 0; i < q; i++){
		int a, v;
		cin >> a >> v;
		add(a, v);
		angler ang = max_person(N);
		printf("%d %d\n", ang.ID, ang.num);
	}
	
	return 0;
}