import sys

input = sys.stdin.readline

MOD = 10 ** 9 + 7
MAXM = 2 * (10 ** 5) + 9
count = [1] + [0] * 9
count_sum = [sum(count)]
for i in range(1, MAXM + 1):
    new_count = [count[(d - 1) % 10] for d in range(10)]
    new_count[1] += count[9]
    if new_count[1] >= MOD:
        new_count[1] -= MOD
    count = new_count
    count_sum.append(sum(count))


def solve(n, m):
    res = 0
    while n > 0:
        res += count_sum[m + n % 10]
        n //= 10
    return res


res = []
t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    res.append(solve(n, m))
print('\n'.join(map(str, res)))