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