import sys
input=sys.stdin.readline

P = 1000000007
M = 200000  
ans_per_digit = [[1 for _ in range(10)] for _ in range(M+1)]
 
for m in range(1,M+1):
    ans_per_digit[m][9] = (ans_per_digit[m-1][0]+ans_per_digit[m-1][1])%P
    for d in range(9):
        ans_per_digit[m][d] = ans_per_digit[m-1][d+1]
 
t = int(input())
for _ in range (t):
    n,m = map(int,input().split())
    a = [int(c) for c in str(n)]
    ans=0
    for di in a:
        ans = (ans+ans_per_digit[m][di])%M
    #print (ans)
    sys.stdout.write(str(ans)+'\n');