m = int(eval(input()))

d = [list(map(int, input().split())) for _ in range(m)]

print((sum([x[1] for x in d]) - 1 + (sum([x[0]*x[1] for x in d]) - 1) // 9))

M=int(eval(input()))

#Get the number that needs to be handled

num=''

D,C=[],[]

for _ in range(M):

    D1,C1=list(map(int, input().split()))

    D.append(D1)

    C.append(C1)

S = sum(d * c for d, c in zip(D, C))

print((sum(C)-1+(S-1)//9))
m = int(eval(input()))
d = [list(map(int, input().split())) for _ in range(m)]
print((sum([x[1] for x in d]) - 1 + (sum([x[0] * x[1] for x in d]) - 1) // 9))

M = int(eval(input()))
# Get the number that needs to be handled
num = ""
D, C = [], []
for _ in range(M):
    D1, C1 = list(map(int, input().split()))
    D.append(D1)
    C.append(C1)
S = sum(d * c for d, c in zip(D, C))
print((sum(C) - 1 + (S - 1) // 9))

-m = int(eval(input())) -d = [list(map(int, input().split())) for _ in range(m)] -print((sum([x[1] for x in d]) - 1 + (sum([x[0] * x[1] for x in d]) - 1) // 9)) +M = int(eval(input())) +# Get the number that needs to be handled +num = "" +D, C = [], [] +for _ in range(M): +    D1, C1 = list(map(int, input().split())) +    D.append(D1) +    C.append(C1) +S = sum(d * c for d, c in zip(D, C)) +print((sum(C) - 1 + (S - 1) // 9))