A, B, C = map(int, input().split("^")) mod = 10 ** 9 + 7 ans1 = pow(A, B * C, mod) ind = pow(B, C, mod - 1) ans2 = pow(A, ind, mod) print(ans1, ans2)