import sys
DIV = 10 ** 9 + 7

def init(m):
    mem = [1] * 10 + [0] * m
    for i in range(10, m+10):
        mem[i] = (mem[i-9] + mem[i-10]) % DIV
    return mem


def count(in_list, m, mem):
    out = 0
    for dig in n:
        out = (out + mem[m+int(dig)] % DIV)
    sys.stdout.write(str(out)+"\n")

#ns = time.time_ns()
#print("ms", (time.time_ns() - ns) // 1e6)
if __name__ == "__main__":
    max_m = int(2*1e5)
    mem = init(max_m)
    num = int(input())
    for _ in range(num):
        n, m = [el for el in sys.stdin.readline().split()]
        count(n, int(m), mem)
    #print(mem[:50])