#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> P;

vector<P> data(2 * (1 << 20)); 

int n;

void init(int k, int l, int r) {
	data[k].first = l;
	data[k].second = 0;
	if (r-l == 1) {
	} else {
		int chl = k*2+1;
		int chr = k*2+2;
		init(chl, l, (l+r)/2);
		init(chr, (l+r)/2, r);
	}
}

void update(int k, int a) {
	k += (1 << 20)-1;
	data[k].second += a;
	while (k > 0) {
		k = (k-1)/2;
		if (data[k*2+1].second >= data[k*2+2].second) {
			data[k].first = data[k*2+1].first;
			data[k].second = data[k*2+1].second;
 		} else {
			data[k].first = data[k*2+2].first;
			data[k].second = data[k*2+2].second;
		}
	}
}

int main() {
	int q;
	cin >> n >> q;
	int a, v;
	init(0, 0, (1 << 20));
	for (int i = 0; i < q; i++) {
		cin >> a >> v;
		update(a-1, v);
		cout << data[0].first+1 << ' ' << data[0].second << endl;
	}
	return 0;
}