t=int(input())
for i in range(t):
    s= input()
    l=[j for j in s.split(' ')]
    ll= [int(j) for j in list(l[0])]
    for k in range(int(l[1])):
        for m in range(len(ll)):
            ll[m]+=1
    s=''
    for n in ll:
       s=s+str(n)
       
    print(len(s)%(1000000007))