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