mod = 10**9+7
def split(n):
    lst = list(str(n))
    for i in range(len(lst)):
        lst[i] = str(int(lst[i])+1)
    return int("".join(lst))

for _ in range(int(input())):
    n,m = map(int,input().split())
    for i in range(m):
        n = split(n)
print(len(str(n))%mod)