class Integer
  def steps
    1.upto(self).to_a
  end
end

class Deck

  def initialize(n)
    @cards = n.steps #=> [1,2...n]
  end

  def cut(r)
    # r == カット回数
    r.times do
      p_c = gets.chomp.split(" ")
      p = p_c[0].to_i
      c = p_c[1].to_i

      cards_bundle = fetch_cards(p,c)
      @cards.concat(cards_bundle)
    end 
    @cards
  end 

  def fetch_cards(p,c)
    bundle = @cards[-p-c+1..-p]
    @cards.slice!(-p-c+1..-p)
    bundle
  end 

  def top 
    @cards.last
  end 

end

loop do
  input = gets.chomp
  break if input == "0 0"
  n = input.split(" ")[0].to_i
  r = input.split(" ")[1].to_i
  deck = Deck.new(n)
  puts deck.cut(r).last
end