import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

import io,os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
mi = lambda :map(int,input().split())
li = lambda :list(mi())

memo_l = [0 for i in range(2*10**5+1)]
memo_l[0] = 1
mod = 10**9 + 7

pre = [0 for i in range(10)]
pre[9] = 1

for i in range(1,2*10**5+1):
    nine = pre[9]
    for j in range(9,0,-1):
        pre[j] = pre[j-1]
    pre[0] = nine
    pre[1] += nine
    pre[1] %= mod

    memo_l[i] = sum(pre) % mod

for _ in range(int(input())):
    n,m = input().split()
    m = int(m)
    digit = [int(d) for d in n]
    res = 0
    for d in digit:
        if d+m<=9:
            res += 1
        else:
            res += memo_l[m+d-9]
    print(res%mod)
