#include<iostream>

using namespace std;

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

	cin >> n >> q;

	plyr = new int[n];
	
	for (int i = n-1; i >= 0; --i)
		plyr[i] = 0;

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

		cin >> a >> v;

		plyr[a-1] += v;

		if (v > 0){
			if (plyr[a - 1] > plyr[max])
				max = a - 1;
			
			else if (plyr[a - 1] == plyr[max]){
				if (a-1 < max)
					max = a - 1;
			}			
		}

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

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

}