#include<iostream>
#include<vector>
#include<algorithm>

int main(){

	int n, q;
	std::cin >> n >> q;

	std::vector<int>v(n, 0);

	for (int i = 0; i < q; i++){

		int a, b;
		std::cin >> a >> b;
		a--;

		v[a] += b;

		int max = v[0];
		for (int j = 1; j < n; j++)max = std::max(max, v[j]);
		for (int j = 0; j < n; j++){
			if (v[j] == max){
				std::cout << j + 1 << " " << v[j] << std::endl;
				break;
			}
		}
	}

	return 0;
}