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;


/*MLE
class Node {
public:
	Node l;
	Node r;
	int maxN;
	int maxV;
	int ln;
	int rn;
	this(int n, int v){
		this.maxN = n;
		this.maxV = v;
		ln = n;
		rn = n;
	}
	this(Node l, Node r){
		this.l = l;
		this.r = r;
		this.ln = l.ln;
		this.rn = r.rn;
		if(l.maxV >= r.maxV) {
			this.maxV = l.maxV;
			this.maxN = l.maxN;
		} else {
			this.maxV = r.maxV;
			this.maxN = r.maxN;
		}
	}
}

Node mkTree(Node[] nodes) {
	if(nodes.length == 1)
		return nodes[0];
	Node[] nodeque = nodes.dup;
	Node[] newnodes;
	while(nodeque.length > 1) {
		newnodes ~= new Node(nodeque[0], nodeque[1]);
		nodeque = nodeque.drop(2);
	}
	if(!nodeque.empty())
		newnodes ~= nodeque[0];
	return mkTree(newnodes);
}
void updateTree(Node node, int n, int dv) {
	with(node) {
		if(ln == n && rn == n) {
			maxV += dv;
		} else {
			if(l.rn >= n){
				updateTree(l, n, dv);
			} else {
				updateTree(r, n, dv);
			}
			if(l.maxV >= r.maxV) {
				maxV = l.maxV;
				maxN = l.maxN;
			} else {
				maxV = r.maxV;
				maxN = r.maxN;
			}
		}
	}
}

void main() {
	auto nq = readln().strip().split();
	int n = to!int(nq[0]);
	int q = to!int(nq[1]);
	Node[] leaves;
	foreach(int i; 0..n) {
		leaves ~= new Node(i+1, 0);
	}
	auto tree = mkTree(leaves);
	foreach(int i; 0..q) {
		auto av = readln().strip().split();
		int a = to!int(av[0]);
		int v = to!int(av[1]);
		updateTree(tree, a, v);
		writefln("%d %d", tree.maxN, tree.maxV);
	}
}
*/


class p{
	int n;
	int v;
}

p getMax(p[] plist) {
	p pmax = new p;
	foreach(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(i; 0..n) {
		plist[i] = new p;
	}

	foreach(i; 0..n) {
		plist[i].n = i;
		plist[i].v = 0;
	}
	int b = max(1,to!int(sqrt(to!real(n))));
	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);
	}
}