a, n = map(int, input().split()) M = 10 ** 7 def remainder(a, n): return a ** n % M print(M) print(remainder(a, n))