from __future__ import division
from sys import stdin, stdout


def fast2():
    import os, sys, atexit
    from cStringIO import StringIO as BytesIO
    # range = xrange
    sys.stdout = BytesIO()
    atexit.register(lambda: os.write(1, sys.stdout.getvalue()))
    return BytesIO(os.read(0, os.fstat(0).st_size)).readline


input = fast2()
rint = lambda: int(stdin.readline())
rints = lambda: [int(x) for x in input().split()]
pr = lambda args, sep: stdout.write(sep.join(map(str, args)) + '\n')
ceil1, out = lambda a, b: (a + b - 1) // b, []

mem = [0] * 10
mem[9], mem2, mod = 1, [1], 10 ** 9 + 7

for i in range(2 * 10 ** 5):
    new = [0] * 10
    for j in range(9):
        new[j + 1] = mem[j]

    new[0] = (mem[9] + new[0]) % mod
    new[1] = (mem[9] + new[1]) % mod

    mem = new
    mem2.append(sum(mem) % mod)

for _ in range(int(input())):
    ans = 0
    n, m = rints()
    for i in str(n):
        if i == '9':
            ans = (ans + mem2[m]) % mod
        elif m - (9 - int(i)) <= 0:
            ans = (ans + 1) % mod
        else:
            ans = (ans + mem2[m - (9 - int(i))]) % mod

    out.append(ans)

pr(out, '\n')
