import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.typecons;



alias p = Tuple!(int, "n", int, "v");

p getMax(p[] plist) {
	p pmax;
	foreach(p ptmp; plist){
		if(pmax.v < ptmp.v) {
			pmax = ptmp;
		}
	}
	return pmax;
}

void main() {
	auto nq = readln().strip().split();
	int n = to!int(nq[0]);
	int q = to!int(nq[1]);

	p[] plist = new p[](n);
	foreach(int i; 0..n) {
		plist[i].n = i;
		plist[i].v = 0;
	}
	int b = 1000;
	p[] seg = new p[]((n+b-1)/b);
	foreach(i; 0..seg.length) {
		seg[i] = plist[i*b];
	}

	foreach(int i; 0..q) {
		auto av = readln().strip().split();
		int a = to!int(av[0]);
		int v = to!int(av[1]);
		plist[a-1].v += v;
		seg[(a-1)/b] = getMax(plist[b*((a-1)/b)..min(n, b*((a-1)/b+1))]);
		p maxp = getMax(seg);
		writefln("%d %d", maxp.n+1, maxp.v);
	}
}