#include <iostream>
using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	int* fish = new int[n];
	for (int i = 0; i < n; ++i) {
		fish[i] = 0;
	}

	int max = 0;
	for (; q; --q) {
		int a, v;
		cin >> a >> v;
		fish[a - 1] += v;
		
		if (max == a - 1 && v < 0) {
			for (int i = 0; i < n; ++i) {
				if (fish[max] < fish[i]) {
					max = i;
				}
			}
		}
		else if (max != a - 1 && fish[max] < fish[a - 1]) {
				max = a - 1;
		}
		else if (max > a - 1 && fish[max] == fish[a - 1]) {
				max = a - 1;
		}
		cout << max + 1 << ' ' << fish[max] << endl;
	}

	delete[] fish;
	return 0;
}