#include <iostream>
using namespace std;

int main() {
	int fish[1000000];
	int q;
	int n;
	cin >> n >> q;
	while(q--) {
		int a, v;
		cin >> a >> v;
		fish[a-1] += v;
		int max = fish[0];
		int max_id = 0;
		for(int i = 1; i < n; i++) {
			if (max < fish[i]) {
				max = fish[i];
				max_id = i;
			}
		}
		cout << max_id+1 << " " << max << endl;
	}
}