#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, q, a, v, max_id, max_fish = -1;
	cin >> n >> q;
	vector <pair<int, int> > player;

	while(q--) {
		cin >> a >> v;
		auto v1 = v;
		for(auto& x: player) {
			if(x.first == a) {
				x.second += v;
				v1 = x.second;
				break;
			}
		}
		if (v == v1) {
			player.push_back(make_pair(a, 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(auto x: player) {
				if (x.second > max_fish || (x.second == max_fish && x.first < max_id) ) {
					max_id = x.first;
					max_fish = x.second;
				}
			}
		}
		cout << max_id << " " << max_fish << endl;
	}
}