M=1000000007
for _ in range(int(input())):

    n,m=map(int,input().split())
    a=[]
    while n!=0:
        a.append(n%10)
        n=n//10
    a=a[::-1]
    for i in range(m):
        for j in range(len(a)):
            a[j]=a[j]+1
    s=''
    for i in a:
        s=s+str(i)
    print(len(s)%M)