import sys
input=sys.stdin.readline
def solve(n,m):
    if m==0:
        print(len(n)%(10**9+7))
        exit(0)
        return len(n)
    n1=list(n)
    for i in range(len(n1)):
        n1[i]=str(int(n1[i])+1)
    n="".join(map(str,n1))
    return solve(n,m-1)

for _ in range(int(input())):
    n,m=map(int,input().split())
    n=str(n)
    solve(n,m)
