p, k = map(int, input().split()) mod = 10 ** 9 + 7 q = (pow(10, p-1, mod) - 1) * pow(p, mod-2, mod) ans = q + int(k <= 1) print(ans%mod)