#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; template T pow_ (T x, T n, int M){ uint64_t u = 1, xx = x; while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; } return static_cast(u); }; int main() { ll a, b, c; scanf("%lld^%lld^%lld", &a, &b, &c); if(a%MOD == 0) { puts("0 0"); return 0; } cout << pow_(pow_(a%MOD, b, MOD), c, MOD) << " "; cout << pow_(a%MOD, pow_(b%(MOD-1), c, MOD-1), MOD) << "\n"; return 0; }