def shuffle(card_list, p, c)
  start = card_list.length - (p + c -1)
  take_out_list = card_list.slice!(start, c)
  card_list.concat(take_out_list)
end
loop do
  card_num, shuffle_num = gets.chomp.split(" ").map {|item| item.to_i }
  if card_num == 0 && shuffle_num == 0
   exit
  end
  card_list = [*1..card_num] # [*1..5] => [1,2,3,4,5]
  shuffle_num.times do |i|
   p, c = gets.chomp.split(" ").map {|item| item.to_i }
   card_list = shuffle(card_list, p, c)
  end
  puts card_list.last
end
