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: # encoding: utf-8
  def create_deck(deck_size):
      deck = []
      for i in range(0, deck_size):
          deck.append(i + 1)
      return deck
  
  
  def shuffle_deck(deck, start, cut_size):
      after = []
      cut_cards = []
      b = len(deck) - cut_size - start
      for i in range(0, len(deck)):
          if b >= i:
              after.append(deck[i])
              continue
          if (b + cut_size) >= i:
              cut_cards.append(deck[i])
              continue
          after.append(deck[i])
      after.extend(cut_cards)
      return after
  
  
  while True:
      data = input().split()
      deck_size, shuffle_count = int(data[0]), int(data[1])
      if deck_size == shuffle_count == 0:
          break
      deck = create_deck(deck_size)
      for i in range(0, shuffle_count):
          cut_info = data = input().split()
          start, cut_size = int(cut_info[0]), int(cut_info[1])
          deck = shuffle_deck(deck, start, cut_size)
      print(deck[len(deck) - 1])
  
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"}]