t = int(input())
for i in range(t):
    nm = input().split()
    n = list(nm[0])
    n = [int(a) for a in n]
    m = int(nm[1])
    for i1 in range(m):
        for i2 in range(len(n)):
            if n[i2]==10:
                n = [str(b) for b in n]
                n = "".join(n)
                n= list(n)
                n = [int(a) for a in n]
            n[i2] += 1
    n = [str(b) for b in n]
    n = "".join(n)
    print(len(n)%(10**9+7))