import sys



def answer():

    input = sys.stdin.readline

    M = int(eval(input()))



    Ds = [0] * M

    Cs = [0] * M

    total = 0



    for i in range(M):

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

        Cs[i] = c

        Ds[i] = d

        total += d * c



    digits = sum(Ds)



    ans = (digits-1) + (total-1) // 9



    print(ans)





if __name__ == '__main__':

    answer()

import sys



def answer():

    input = sys.stdin.readline

    M = int(eval(input()))



    digits = 0

    total = 0



    for i in range(M):

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

        digits += d

        total += d * c



    ans = (digits-1) + (total-1) // 9



    print(ans)





if __name__ == '__main__':

    answer()

import sys


def answer():
    input = sys.stdin.readline
    M = int(eval(input()))
    Ds = [0] * M
    Cs = [0] * M
    total = 0
    for i in range(M):
        c, d = list(map(int, input().split()))
        Cs[i] = c
        Ds[i] = d
        total += d * c
    digits = sum(Ds)
    ans = (digits - 1) + (total - 1) // 9
    print(ans)


if __name__ == "__main__":
    answer()

import sys


def answer():
    input = sys.stdin.readline
    M = int(eval(input()))
    digits = 0
    total = 0
    for i in range(M):
        c, d = list(map(int, input().split()))
        digits += d
        total += d * c
    ans = (digits - 1) + (total - 1) // 9
    print(ans)


if __name__ == "__main__":
    answer()

-    Ds = [0] * M -    Cs = [0] * M +    digits = 0 -        Cs[i] = c -        Ds[i] = d +        digits += d -    digits = sum(Ds)