output_description: For each data set in the input, your program should write the number of the
  top card after the shuffle. Assume that at the beginning the cards are
  numbered from 1 to _n_ , from the bottom to the top. Each number should be
  written in a separate line without any superfluous characters such as leading
  or following spaces.
input_description: The input consists of multiple data sets. Each data set starts with a line
  containing two positive integers _n_ (1 <= _n_ <= 50) and _r_ (1 <= _r_ <=
  50); _n_ and _r_ are the number of cards in the deck and the number of cutting
  operations, respectively.
  
  There are _r_ more lines in the data set, each of which represents a cutting
  operation. These cutting operations are performed in the listed order. Each
  line contains two positive integers _p_ and _c_ (_p_ \+ _c_ <= _n_ \+ 1).
  Starting from the _p_ -th card from the top of the deck, _c_ cards should be
  pulled out and put on the top.
  
  The end of the input is indicated by a line which contains two zeros.
  
  Each input line contains exactly two integers separated by a space character.
  There are no other characters in the line.
attempt: while 1:
      count, times = [int(a) for a in input().split()]
      hanahuda = [i + 1 for i in range(count)]
      if count == times == 0:
          break
      for i in [0] * times:
          p, c = [int(i) for i in input().split()]
          for i in [0] * c:
              hanahuda.append(hanahuda.pop(count - (p + c) + 1))
      print(hanahuda.pop())
  
problem_description: Problem A: Hanafuda Shuffle
  
  There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for
  Japanese card game 'Hanafuda' is one such example. The following is how to
  perform Hanafuda shuffling.
  
  There is a deck of _n_ cards. Starting from the _p_ -th card from the top of
  the deck, _c_ cards are pulled out and put on the top of the deck, as shown in
  Figure 1. This operation, called a cutting operation, is repeated.
  
  Write a program that simulates Hanafuda shuffling and answers which card will
  be finally placed on the top of the deck.
  
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_hanafuda)  
  ---  
  Figure 1: Cutting operation
samples: [{"input": "2\n    3 1\n    3 1\n    10 3\n    1 10\n    10 1\n    8 3\n    0 0", "output": "4"}]