'''No.2007 Arbitrary Mod (Easy) ''' a, n = map(int, input().split()) assert 2 <= a <= 1000 assert 2 <= n <= 10 ** 18 M = 10 ** 7 print(M) print(a ** n % M)