import sys



m = int(eval(input()))

csum = 0

dsum = 0

for i in range(m):

  d,c = list(map(int,input().split()))

  csum += c

  dsum += d*c

print((csum-1 + (dsum-1) // 9))

import sys

input = sys.stdin.readline

m = int(eval(input()))

csum = 0

dsum = 0

for i in range(m):

  d,c = list(map(int,input().split()))

  csum += c

  dsum += d*c

print((csum-1 + (dsum-1) // 9))

import sys

m = int(eval(input()))
csum = 0
dsum = 0
for i in range(m):
    d, c = list(map(int, input().split()))
    csum += c
    dsum += d * c
print((csum - 1 + (dsum - 1) // 9))

import sys

input = sys.stdin.readline
m = int(eval(input()))
csum = 0
dsum = 0
for i in range(m):
    d, c = list(map(int, input().split()))
    csum += c
    dsum += d * c
print((csum - 1 + (dsum - 1) // 9))

+input = sys.stdin.readline