#define _CRT_SECURE_NO_WARNINGS #include using namespace std; #define int long long const int MOD = 1000000000 + 7; int Pow(int x, int n, int mod) { x %= mod; n %= mod - 1; if (x == 0) return 0; if (n == 0) return 1; int ret = Pow(x*x % mod, n/2, mod); if (n&1) (ret *= x) %= mod; return ret; } int A, B, C; signed main() { scanf("%lld^%lld^%lld", &A, &B, &C); printf("%lld %lld\n", Pow(Pow(A, B, MOD), C, MOD), Pow(A, Pow(B, C, MOD - 1), MOD)); return 0; }