def ascan; gets.split.map(&:to_i);end

loop do
    n,r = ascan
    break if n == 0 && r == 0
    cards = (1..n).to_a.reverse
    r.times do
        i, c = ascan
        i-=1
        cards = (cards[i...(i+c)]||[]) + (cards[0...i]||[]) + (cards[(i+c)..-1]||[])
    end
    p cards[0]
end
