import math
import sys
input = sys.stdin.readline
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input().strip()
    return(list(s[:len(s)]))
def invr():
    return(map(int,input().split()))
mx=10**9+7
dp=[0 for i in range(2*10**5 + 100)]
for i in range(10):
    dp[i]=1
for i in range(10,2*10**5+2):
    dp[i]=(dp[i-9]+dp[i-10])%mx
for _ in range(inp()):
    n,m=invr()
    l=list(map(int,str(n)))
    c=0
    for each in l:
        c+=dp[each+m]
    print(c%mx)