#include <cstdio>
#include <queue>
#define MAX 1000001
using namespace std;
typedef pair<int, int> PAIR;

int main(){
	int n, q, a, v, array[MAX];
	fill(array, array + 1000001, 0);
	
	priority_queue<PAIR> que;
	
	scanf("%d %d", &n, &q);
	for(int i = 0; i < q; i++){
		scanf("%d %d", &a, &v);
		array[a] += v;
		que.push(PAIR(array[a], -a));
		
		while(true){
			PAIR pai = que.top();
			if(pai.first <= array[-pai.second]) {
				printf("%d %d\n", -pai.second, pai.first);
				break;
			}
			que.pop();
		}
	}
	return 0;
}