def main():
    import sys
    input = sys.stdin.buffer.readline
    t = int(input())
    mod = 10**9 + 7

    X = [0]*(2*10**5 + 11)
    X[0] = 1
    A = [0]*(2*10**5 + 11)
    X[0] = 1
    A[9] = 1
    for i in range(2*10**5 + 11):
        A[i] += A[i-9]
        A[i] += A[i-10]
        A[i] %= mod

    for i in range(1, 2*10**5 + 11):
        X[i] = X[i-1]
        X[i] += A[i-1]
        X[i] %= mod

    for _ in range(t):
        n, m = map(int, input().split())
        ans = 0
        if n == 0:
            ans = X[m]
        else:
            while(n):
                ans += X[m+(n % 10)]
                n //= 10
        print(ans)


main()
