### main

loop do
  n, r = gets.split.map(&:to_i)
  break if (n | r) == 0

  cards = (1..n).to_a.reverse

  r.times do
    pn, cn = gets.split.map(&:to_i)
    pn -= 1
    cards0 = cards[pn, cn] + cards[0, pn] + cards[(pn + cn)...n]
    cards = cards0
  end

  puts cards.first
end