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

#define MAX_PLAYER 1000000

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