# solve
def solve():
    import sys
    input = sys.stdin.readline
    def LI(): return input().split()
    def II(): return int(input())
    mod = 1000000007
    t = II()
    dp = [None] * (2 * 10 ** 5 + 10)
    for i in range(2 * 10 ** 5 + 10):
        dp[i] = [0] * 10
    dp[0][0] = 1
    dpi = dp[0]
    for i in range(2 * 10 ** 5 + 9):
        dpi1 = dp[i + 1]
        dpi1[0] = dpi[9]
        dpi1[1] = dpi[9]
        for j in range(9):
            dpij = dpi[j]
            dpi1[j + 1] += dpij
            if dpi1[j + 1] >= mod:
                dpi1[j + 1] %= mod
        dpi = dpi1
    for i in range(2 * 10 ** 5 + 10):
        dp[i] = sum(dp[i])
    for _ in range(t):
        n, m = LI()
        m = int(m)
        ans = 0
        for ni in n:
            ans += dp[m + ni]
            if ans >= mod:
                ans %= mod
        print(ans)
    return
 