import sys sys.set_int_max_str_digits(0) MOD = 129402307 N = input() M = input() ans = pow(int(N), int(M), MOD) print(ans)