MOD = 10**9 + 7
length = [2] * 9 + [3]
for m in range(10, 2 * 10**5 + 1):
    length.append((length[m - 9] + length[m - 10]) % MOD)

T = int(input())
for t in range(1, T + 1):
    N, M = map(int, input().split())

    result = 0
    while N > 0:
        result += 1 if M + N % 10 < 10 else length[M - 10 + N % 10]
        result %= MOD
        N //= 10
    print(result)
print('end')