M = int(eval(input()))

ans, s = 0, 0



for _ in range(M):

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

    s += d*c

    ans += c



ans += (s-1)//9 - 1

print(ans)

import sys

input=sys.stdin.readline





def solve():

    M = int(eval(input()))

    ans, s = 0, 0



    for _ in range(M):

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

        s += d*c

        ans += c



    ans += (s-1)//9 - 1

    print(ans)



solve()

M = int(eval(input()))
ans, s = 0, 0
for _ in range(M):
    d, c = list(map(int, input().split()))
    s += d * c
    ans += c
ans += (s - 1) // 9 - 1
print(ans)

import sys

input = sys.stdin.readline


def solve():
    M = int(eval(input()))
    ans, s = 0, 0
    for _ in range(M):
        d, c = list(map(int, input().split()))
        s += d * c
        ans += c
    ans += (s - 1) // 9 - 1
    print(ans)


solve()

-M = int(eval(input())) -ans, s = 0, 0 -for _ in range(M): -    d, c = list(map(int, input().split())) -    s += d * c -    ans += c -ans += (s - 1) // 9 - 1 -print(ans) +import sys + +input = sys.stdin.readline + + +def solve(): +    M = int(eval(input())) +    ans, s = 0, 0 +    for _ in range(M): +        d, c = list(map(int, input().split())) +        s += d * c +        ans += c +    ans += (s - 1) // 9 - 1 +    print(ans) + + +solve()