def solve_tc():
    n, m = map(str, input().split())
    m = int(m)
    n = list(n)
    for i in range(len(n)):
        n[i] = int(n[i])
    d = {}
    cnt = 0
    for i in range(10):
        d[i] = 0
    for i in n:
        d[i] = d[i] + 1
    for j in range(m):
        nines = d[9]
        for i in [8, 7, 6, 5, 4, 3, 2, 1, 0]:
            d[i + 1] = d[i]
        d[0] = int((d[0] + nines) % (10e9 + 7))
        d[1] = int((d[1] + nines) % (10e9 + 7))
    for i in d:
        cnt += d[i]
    return cnt


t = int(input())
while t > 0:
    t -= 1
    print(solve_tc())