for _ in range(int(input())):
    n,m = map(str,input().split())
    arr = []
    for i in n:
        arr.append(int(i))
    for i in range(int(m)):
        for j in range(len(arr)):
            arr[j]+=1
    c = ''.join(map(str,arr))
    rem = len(c)%(10**9 +7)
    print(rem)