t=int(input())
for _ in range(t):
    n,m=map(int,input().split())
    for i in range(m):
        sn=str(n)
        new=""
        for j in range(len(sn)):
            new+=str(int(sn[j])+1)
        n=int(new)
    print(n%(10**9+7))