while true
	n,r = gets.split(" ").map{|e|e.to_i}
	break if n==0 && r==0
	array=Array.new n
	n.times{|t|array[t]=n-t}
	r.times{
		p,c = gets.split(" ").map{|e|e.to_i}
		array=array[p-1..p+c-2]+array[0..p-2]+array[p+c-1..n-1]
	}
	p array[0]
end