#include <iostream>

using namespace std;
#define MAX_EVENT 100000

int main() {
	int n, q, a, v, max_id, max_fish = -1;
	cin >> n >> q;
	int* player_id = new int [MAX_EVENT+1];
	int* player_fish = new int [MAX_EVENT+1];
	int entry = 0;

	while(q--) {
		cin >> a >> v;
		auto v1 = v;
		for(int i = 0; i < entry; i++) {
			if(player_id[i] == a) {
				v1 = player_fish[i] += v;
				break;
			}
		}
		if (v == v1) {
			player_id[entry] = a;
			player_fish[entry++] = v;
		}
		if (v1 > max_fish || (v1 == max_fish && a < max_id)) {
			max_id = a;
			max_fish = v1;
		} 
		if (v < 0 && max_id == a) {
			max_fish = -1;
			for(int i = 0; i < entry; i++) {
				if (player_fish[i] > max_fish || (player_fish[i] == max_fish && player_id[i] < max_id) ) {
					max_id = player_id[i];
					max_fish = player_fish[i];
				}
			}
		}
		cout << max_id << " " << max_fish << endl;
	}
}