a, b, c = map(int, input().split("^")) mod = 10 ** 9 + 7 x = pow(pow(a, b, mod), c, mod) y = pow(a, pow(b, c, mod - 1), mod) print(x, y)