import sys
input=sys.stdin.readline

maxi=2*(10**5)
mod=10**9+7
dp=[[1 for _ in range(10)] for _ in range(maxi+1)]
for i in range(1,maxi+1):
    for j in range(10):
        if(j!=9):
            dp[i][j]=dp[i-1][j+1]
        else:
            dp[i][j]=(dp[i-1][0]+dp[i-1][1])%mod


for _ in range(int(input())):
    n,m=map(int,input().split())
    ans=0
    while(n>0):
        ans=(ans+dp[m][n%10])%mod
        n=n//10
    print(sys.stdout.write(str(ans)))

