output_description: Print the maximum possible number of rounds in the preliminary stage.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      M
      d_1 c_1
      d_2 c_2
      :
      d_M c_M
attempt: m, *t = map(int, open(0).read().split())
  a = b = 0
  for d, c in zip(*[iter(t)] * 2):
      m = [b]
      while c // 2:
          cd = c // 2
          a += cd
          if c % 2:
              m += (d,)
          d *= 2
          if d > 9:
              a += cd
              d = d // 10 + d % 10
          c = cd
      for t in m[::-1]:
          d += t
          a += 1
          if d > 9:
              d = d // 10 + d % 10
              a += 1
      b = d
  print(a - 1)
  
problem_description: Statement
  
  N programmers are going to participate in the preliminary stage of DDCC 20XX.
  Due to the size of the venue, however, at most 9 contestants can participate
  in the finals.
  
  The preliminary stage consists of several rounds, which will take place as
  follows:
  
    * All the N contestants will participate in the first round.
    * When X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows:
      * The organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round.  
  For example, when X = 2378, the number of contestants advancing to the next
  round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or
  2315 (if 7 and 8 are chosen).  
  When X = 100, the number of contestants advancing to the next round will be
  10, no matter which two digits are chosen.
  
    * The preliminary stage ends when 9 or fewer contestants remain.
  
  Ringo, the chief organizer, wants to hold as many rounds as possible. Find the
  maximum possible number of rounds in the preliminary stage.
  
  Since the number of contestants, N, can be enormous, it is given to you as two
  integer sequences d_1, \ldots, d_M and c_1, \ldots, c_M, which means the
  following: the decimal notation of N consists of c_1 + c_2 + \ldots + c_M
  digits, whose first c_1 digits are all d_1, the following c_2 digits are all
  d_2, \ldots, and the last c_M digits are all d_M.
samples: [{"input": "2\n    2 2\n    9 1", "output": "3\n    \n\nIn this case, N = 229 contestants will participate in the first round. One\npossible progression of the preliminary stage is as follows:\n\n  * 229 contestants participate in Round 1, 49 contestants participate in Round 2, 13 contestants participate in Round 3, and 4 contestants advance to the finals.\n\nHere, three rounds take place in the preliminary stage, which is the maximum\npossible number.\n\n* * *"}, {"input": "3\n    1 1\n    0 8\n    7 1", "output": "9\n    \n\nIn this case, 1000000007 will participate in the first round."}]