from collections import defaultdict
def main(n,m):
    mod=10**9+7
    hash=defaultdict(lambda:0)
    while n:
        x=n%10
        n=n//10
        hash[x]+=1
    for i in range(m):
        temp=defaultdict(lambda:0)
        for key,value in hash.items():
            if key!=9:
                temp[key]-=value
                temp[key+1]+=value
            else:
                temp[1]=(temp[1]+value%mod)%mod
                temp[0]=(temp[0]+value%mod)%mod
        hash=hash.clear()
        hash=temp
    return sum(list(temp.values()))%mod
t=int(input())
for test in range(t):
    n,m=map(int,input().split())
    print(main(n,m))