#include const int mm = 1000000007; long long pow(long long a, long long p, int mod) { if(!p) return 1LL; long long res = pow(a, p>>1, mod); res *= res; res %= mod; if(p&1) { res *= a%mod; res %= mod; } return res; } int main() { long long a, b, c; scanf("%lld^%lld^%lld", &a, &b, &c); printf("%lld %lld\n", pow(pow(a, b, mm), c, mm), pow(a, pow(b, c, mm-1), mm)); }