prime=(10**9)+7


def solve(n,m):
    ans=''
    n=str(n)
    l1=[]
    for i in range(0,len(n)):
        l1.append(int(n[i])+m)
    
    for item in l1:
        ans+=str(item)

    return len(ans)%prime



if __name__=='__main__':
    t=int(input())

    for _ in range(t):
        l1=input().split(' ')
        print(solve(int(l1[0]),int(l1[1])))