#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	int c,d;
	int x[a+1];
	for(int i=0;i<=a;i++) x[i] = 0;
	int maxv = 0;
	int maxp = 1;
	for(int i=0;i<b;i++){
		cin >> c >> d;
		x[c] += d;
		if(c==maxp){
			maxv = x[c];
			if(d<0){
				for(int j=1;j<=a;j++){
					if(j==maxp) continue;
					if(maxv==x[j] and j<maxp) maxp = j;
					else if(maxv<x[j]){
						maxv = x[j];
						maxp = j;
					}
				}
			}
		}
		else{
			if(maxv==x[c] and c<maxp) maxp = c;
			else if(maxv<x[c]){
				maxv = x[c];
				maxp = c;
			}
		}
		cout << maxp << " " << maxv << endl;
	}
}