#include using namespace std; typedef long long int64; const int MOD = 1e9 + 7; int64 pow_mod(int64 x, int64 n, int64 mod = 1e9 + 7) { int64 ret = 1LL; while(n > 0) { if(n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } int main() { long long A, B, C; scanf("%lld^%lld^%lld", &A, &B, &C); printf("%lld %lld\n", pow_mod(A, B % MOD * C % MOD), pow_mod(A, pow_mod(B, C, MOD - 1))); }