loop do
  n, r = gets.split.map(&:to_i)
  break if r == 0 && n == 0
  cards = n.downto(1).to_a
  r.times do
    p, c = gets.split.map(&:to_i)
    cs = cards.slice!(p-1, c)
    cards = cs + cards
  end
  puts cards[0]
end
