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