def solve n, r
  cards = (1..n).to_a
  r.times do
    p, c = gets.chomp.split
    p, c = p.to_i, c.to_i
    pl = n-c-p+1
    c.times do
      cards.push(cards.delete_at(pl))
   end
  end
  puts cards.last
end

loop do
  n, r = gets.chomp.split
  if n=='0' && r=='0'
    break
  end
  solve(n.to_i, r.to_i)
end