#include<iostream>

using namespace std;


int main(){
	int n, q, a, v, max;
	int *plyr;

	cin >> n >> q;

	plyr = new int[n];
	
	for (int i = 0; i < n; ++i)
		plyr[i] = 0;


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

		cin >> a >> v;

		plyr[a-1] += v;

		max = 0;
		for (int j = 0; j < n;++j){
			if (plyr[i]>plyr[max])
				max = i;
		}

		cout << max + 1 << " " << plyr[max] << endl;

	}

	delete[] plyr;

}