#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 = n; i >= 0; --i)
		plyr[i] = 0;

	for (int i = q; i >= 0; --i){

		cin >> a >> v;

		plyr[a-1] += v;

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

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

	}
	delete[] plyr;

}