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