import math
import itertools
from collections import defaultdict

DEBUG = True

def log(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
 
def ri():
    return int(input())
 
def rl(f=int):
    return list(map(f, input().split()))
 
def rs():
    return input()
 
class Solution:
    
    def __init__(self):
        pass
        
    def run(self):

        n, m = rl()

        count = [0] * 11
        for x in str(n):
            count[int(x)] += 1

        for i in range(m):
            if count[10] > 0:
                count[1] += count[10]
                count[0] += count[10]
                count[10] = 0
            for i in range(10, 0, -1):
                count[i] = count[i - 1]

        result = sum(count)

        return result % (10**9 + 7)
        
                
                        
if __name__ == '__main__':

    #test()
    
    t = int(input())
    s = Solution()
    #s.run()
    #print(s.run())
    for i in range(t):
    #    s.run()
        print(s.run())
 
