import sys



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60





def main():

    M, *DC = list(map(int, read().split()))



    total = digits = 0

    for d, c in zip(DC[::2], DC[1::2]):

        total += d * c

        digits += c



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



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys



read = sys.stdin.buffer.read





def main():

    M, *DC = list(map(int, read().split()))



    total = digits = 0

    for d, c in zip(DC[::2], DC[1::2]):

        total += d * c

        digits += c



    print((digits - 1 + (total - 1) // 9))

    return





if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def main():
    M, *DC = list(map(int, read().split()))
    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c
    ans = digits - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.buffer.read


def main():
    M, *DC = list(map(int, read().split()))
    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c
    print((digits - 1 + (total - 1) // 9))
    return


if __name__ == "__main__":
    main()

-read = sys.stdin.read -readline = sys.stdin.readline -readlines = sys.stdin.readlines -sys.setrecursionlimit(10**9) -INF = 1 << 60 +read = sys.stdin.buffer.read -    ans = digits - 1 + (total - 1) // 9 -    print(ans) +    print((digits - 1 + (total - 1) // 9))