#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;


using P = pair<int, int>;


int n;
int q;
P seg[3000000];


int parent(int c){
	return (c - 1) / 2;
}


int nodeN(int i){
	return n + i - 1;
}


int otherC(int node){
	return (2 * parent(node) + 1) < node ? node - 1: node + 1;
}


void update(int c1){
	int c2 = otherC(c1);
	int p = parent(c1);
	while(c1 != 0){
		if(seg[c1].second == seg[c2].second){
			seg[p].first = min(seg[c1].first, seg[c2].first);
			seg[p].second = seg[c1].second;
		}
		else if(seg[c1].second > seg[c2].second){
			seg[p] = seg[c1];
		}
		else {
			seg[p] = seg[c2];
		}
		c1 = p;
		c2 = otherC(c1);
		p = parent(c1);
	}
}


int main(){
	cin >> n >> q;
	n = (int)pow(2, ceil(log2(n)));
	for(int i = 0;i < q;i++){
		int a, v;
		cin >> a >> v;
		a--;
		int node = nodeN(a);
		seg[node].first = a + 1;
		seg[node].second += v;
		update(node);
		cout << seg[0].first << ' ' << seg[0].second << endl;
	}

	return 0;
}