A, B, C = map(int, input().split('^')) mod = 10 ** 9 + 7 print(pow(pow(A, B, mod), C, mod) % mod, pow(A, pow(B, C, mod - 1), mod))