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

typedef pair<int, int> P;

	int n, q;
			int a_i, v_i;
int main() {
cin >> n >> q;

		priority_queue<P> queue;
int fish[100001];
		for (int i = 0; i < q; i++) {

			cin >> a_i >> v_i;
			fish[a_i] += v_i;
			queue.push(make_pair(fish[a_i], -a_i));
			while(1) {
				P top = queue.top();
top.second *= (-1);
				if (top.first == fish[top.second]) {
					cout << top.second << " " << top.first << endl;
					break;
				}
				queue.pop();
			}
		}
	return 0;
}