p, k = map(int, input().split()) mod = 10**9 + 7 x = 0 if k == 0: x = 1 print(((pow(10, p - 1, mod * p) - 1) // p + x) % mod)