MOD=10**9+7
p,k=map(int,input().split())
ans=((pow(10,p-1)-1)+1)//p%MOD
if pow(10,p-1)%p!=p-1 and pow(10,p-1)%p==k:
    ans+=1
print(ans)