N = int(input()) M = int(input()) MOD = 129402307 N %= MOD M %= MOD - 1 print(pow(N, M, MOD))