#include using namespace std; #define rep(i,a,b) for(int i=a;i>= 1; return r; } //----------------------------------------------------------------- ll A, B, C; ll mod = 1000000007; ll solve1() { ll D = modpow(A, B, mod); return modpow(D, C, mod); } ll solve2() { ll D = modpow(B, C, mod - 1); return modpow(A, D, mod); } //----------------------------------------------------------------- int main() { scanf("%lld^%lld^%lld", &A, &B, &C); cout << solve1() << " " << solve2() << endl; }