#include <stdio.h>
#include <vector>
#include <algorithm>


using namespace std;

int* heap_index;

struct Info{
	Info(){
		id=0;
		score = 0;
	}
	Info(int arg_id,int arg_score){
		id = arg_id;
		score = arg_score;
	}
	int id,score;
};

class InfoPQ{
public:
	InfoPQ(int arg_n){
		array = new Info[arg_n];
		n = 0;
	}

	void push(Info arg_info){
		array[n] = arg_info;
		int tmp = n;
		while(tmp != 0 && array[tmp].id < array[(tmp-1)/2].id){
			std::swap(array[tmp], array[(tmp-1)/2]);
			tmp = (tmp-1)/2;
		}
		n++;
	}

	void writeHeapIndex(){
		for(int i=0;i<n;i++){
			heap_index[array[i].id] = i;
		}
	}

	void printTop(){
		printf("%d %d\n",array[0].id,array[0].score);
	}

	void update(int update_id,int div){

		array[heap_index[update_id]].score += div;
		int tmp = heap_index[update_id];

		if(div > 0){
			while(tmp != 0 && ((array[tmp].score > array[(tmp-1)/2].score) || (array[tmp].score ==array[(tmp-1)/2].score && array[tmp].id < array[(tmp-1)/2].id))){
				std::swap(heap_index[array[tmp].id],heap_index[array[(tmp-1)/2].id]);
				std::swap(array[tmp], array[(tmp-1)/2]);
				tmp = (tmp-1)/2;
			}
		}else{
			while(2*tmp+1 <= n-1){
				if(2*tmp+2 <= n-1){
					if(((array[2*tmp+2].score > array[tmp].score) || (array[2*tmp+2].score == array[tmp].score && array[2*tmp+2].id < array[tmp].id)) &&
							((array[2*tmp+2].score > array[2*tmp+1].score) || (array[2*tmp+2].score == array[2*tmp+1].score && array[2*tmp+2].id < array[2*tmp+1].id))){
						std::swap(heap_index[array[tmp].id],heap_index[array[2*tmp+2].id]);
						std::swap(array[2*tmp+2],array[tmp]);
						tmp = 2*tmp+2;
					}else if(((array[2*tmp+1].score > array[tmp].score) || (array[2*tmp+1].score == array[tmp].score && array[2*tmp+1].id < array[tmp].id)) &&
							((array[2*tmp+1].score > array[2*tmp+2].score) || (array[2*tmp+1].score == array[2*tmp+2].score && array[2*tmp+1].id < array[2*tmp+2].id))){
						std::swap(heap_index[array[tmp].id],heap_index[array[2*tmp+1].id]);
						std::swap(array[2*tmp+1],array[tmp]);
						tmp = 2*tmp+1;
					}else{
						break;
					}
				}else{
					if((array[2*tmp+1].score > array[tmp].score) || (array[2*tmp+1].score == array[tmp].score && array[2*tmp+1].id < array[tmp].id)){
						std::swap(heap_index[array[tmp].id],heap_index[array[2*tmp+1].id]);
						std::swap(array[tmp],array[2*tmp+1]);
						tmp = 2*tmp+1;
					}else{
						break;
					}
				}
			}
		}
	}

private:
	Info* array;
	int n;
};



int main(){
	int n,q,id,div;

	scanf("%d %d",&n,&q);

	InfoPQ Q(n);
	heap_index = new int[n+1];

	for(int i = 0; i < n; i++)Q.push(Info(i+1,0));

	Q.writeHeapIndex();

	for(int i = 0; i < q; i++){
		scanf("%d %d",&id,&div);
		Q.update(id,div);
		Q.printTop();
	}

    return 0;
}