#int(input()) #map(int, input().split()) #list(map(int, input().split())) a, n = map(int, input().split()) M = 10 ** 7 print(M) print(pow(a, n, M))