import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

mod = 10**9+7

from itertools import accumulate
def main():
    N = 2*10**5+50
    dp = [0]*(10*N)
    dp[0] = 1
    for i in range(1, N):
        for j in range(10):
            if j != 9:
                dp[10*i+j+1] += dp[10*(i-1)+j]%mod
            else:
                dp[10*i+0] += dp[10*(i-1)+j]%mod
                dp[10*i+1] += dp[10*(i-1)+j]%mod
    dp = [0]+dp
    for i in range(1, N+1):
        dp[i] += dp[i-1]
        dp[i] %= mod

    t = int(input())
    for _ in range(t):
        n, m = map(int, input().split())
        X = [0]*10
        s = str(n)
        for c in s:
            c = int(c)
            X[c] += 1
        ans = 0
        for j in range(10):
            s = 0
            s += dp[10*(m+j)+10]-dp[10*(m+j)]
            ans += s*X[j]
        print(ans%mod)

if __name__ == '__main__':
    main()
