#!/usr/bin/python3 mod = 10**9 + 7 def f1(a, b, c): return pow(pow(a, b, mod), c, mod) def f2(a, b, c): if (c==1 and b>=mod-1) or (c>1 and b>=10**5) or (c>10**5 and b!=1): bcmod1 = pow(b, c, mod-1) return pow(a % mod, bcmod1 + (mod-1), mod) else: return pow(a, b**c, mod) a, b, c = map(int, input().split('^')) r1 = f1(a, b, c) r2 = f2(a, b, c) print(r1, r2)