mod = 129402307
N = int(input())
M = int(input())
print(pow(N, M, mod))