from collections import Counter

q={0:{j:0 for j in range(200019)}}
c=[0 for j in range(10)]
c[0]=1
for j in range(200019):
    d=[]
    d.append(c[9])
    for k in range(9):
        d.append(c[k])
    d[1]+=c[9]
    if j%20==0:
        d=[k%(10**9+7) for k in d]
    q[0][j]=sum(d)%(10**9+7)
    c=d.copy()

t=int(input())
for i in range(t):
    n, m=[int(k) for k in input().split()]
    c=[0 for k in range(10)]
    res=0
    for k in str(n):
        c[int(k)]+=1
    #print(c)
    for j in range(10):
        res+=q[0][m+j]*c[j]
    print(res)