def main():
    t = int(input())
    for _ in range(t):
        n,k = map(int,input().split())
        for j in range(k):
            a = list(str(n))
            for i in range(len(a)):
                a[i] = str(int(a[i])+1)
            n = ''.join(a)
        n = str(int(n)%(10**9+7))
        print(len(n))



if __name__=='__main__':
    main()