#
# Hanafuda shuffle (AOJ id=1129)
#
n, r = gets.chomp.split.map { |s| s.to_i }
while [n,r] != [0,0]
  # p [n,r]
  
  cards = (1..n).to_a
  cards.reverse!
  
  # p cards
  
  r.times do
    _p, c = gets.chomp.split.map { |s| s.to_i}
    u = cards[0, _p-1]
    cards[0, c] = cards[_p-1, c]
    cards[c, _p-1] = u

    # p cards
  end
  puts cards[0]
  
  n, r = gets.chomp.split.map { |s| s.to_i }
end