# Data structure
class Edge
	def initialize(src,dst,cost)
		@src = src
		@dst = dst
		@cost = cost
	end
	def <(another)
		if @cost != another.cost
			return @cost < another.cost
		else
			return @src < another.src
		end
	end

	attr_accessor :src, :dst, :cost
end

# SkewHeap for Priority-Queue
class Heap
	class Node
		def initialize(value)
			@left=nil
			@right=nil
			@value=value
		end
		attr_accessor :value,:right,:left
	end
	
	def initialize()
		@size = 0
		@root = nil
	end

	def meld a,b
		if a == nil
			return b
		end
		if( b == nil )
			return a
		end
		if b.value < a.value 
			a,b=b,a
		end
		a.right = meld(a.right,b)
		a.left,a.right=a.right,a.left
		return a
	end
	
	def top
		@root.value
	end
	
	def pop
		@size -= 1
		@root=meld(@root.left,@root.right)
	end

	def push x
		@size += 1
		@root=meld(@root,Node.new(x))
	end
	attr_accessor :size
end
# Main
n,q=gets.split.map{|n|n.to_i}
g = Array.new(n,0);


que = Heap.new();

q.times{
	a,v=gets.split.map{|n|n.to_i}
	a -= 1;
	g[a] -= v;
	que.push(Edge.new(a,a,g[a]));
	while que.size != 0
		q = que.top()
		if g[q.src] != q.cost
			que.pop()
		else
			break
		end
	end	
	puts "#{que.top().src+1} #{-que.top().cost}"
}