a = gets.split.map(&:to_i)
d = []
while a[0] != 0 && a[1] != 0
	b = []
	a[0].times do |i|
		b.push(i)
	end
	b = b.reverse
	#p b
	a[1].times do 
		c = gets.split.map(&:to_i)
		if c[1] == a[0]
			next
		else
			c[1].times do 
				i = 0
				b.unshift(b[c[0]-1-i])if c[1] == 1
				if c[1] != 1
					i = i + 1
					b.unshift(b[c[0]+c[1]-1-i])
				end
				b = b.uniq
			end
		end
		#p b
	end
	a = gets.split.map(&:to_i)
	d.push(b.shift + 1)
end
puts d