#include <iostream>
#include <utility>
using namespace std;

#define MAX_PLAYER 1000000

int main() {
	struct { int rank; int fish; } player[MAX_PLAYER];
	int ranking[MAX_PLAYER], q, n;
    auto challenge = [&] (int x) {
		int y = ranking[player[x].rank - 1];
    	if (player[x].fish > player[y].fish ||
    	    (player[x].fish == player[y].fish && x < y)) {
    	    swap(ranking[player[x].rank], ranking[player[y].rank]);
    	    swap(player[x].rank, player[y].rank);
    	    return true;
    	} else {
    		return false;
    	}
    };
	cin >> n >> q;
	for(int i = 0; i < n; i++) ranking[i] = player[i].rank = i;
	while(q--) {
		int a, v;
		cin >> a >> v;
		player[--a].fish += v;
		if (v > 0) {
			while (player[a].rank > 0 && challenge(a)) ;
		} else {
			while (player[a].rank < n-1 && challenge(ranking[player[a].rank + 1])) ;
		}
		cout << ranking[0]+1 << " " << player[ranking[0]].fish << endl;
	}
}