a, b, c = map(int, input().split('^')) mod = 1000000007 ans1 = pow(pow(a, b), c) ans2 = pow(a, pow(b, c)) print(ans1, ans2)