#! ruby -Ks

while true
	array = [1]
	line = gets
	line = line.split()
	n = line[0].to_i
	if n == 0
		break
	end
	r = line[1].to_i
	
	for i in 2..n
		array.unshift(i)
	end
	#p array
	
	for i in 1..r
		line = gets
		line = line.split()
		p = line[0].to_i
		c = line[1].to_i
		
		b = array.slice!(p-1,c)
		array[0,0] = b
		#p array
	end
	puts array[0]
end