#include using namespace std; using int64 = long long; int64_t power(int64_t x, int64_t n, int64_t mod) { x %= mod; int64_t ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return (ret); } const int mod = 1e9 + 7; int main() { int64 A, B, C; scanf("%lld^%lld^%lld", &A, &B, &C); cout << power(power(A, B, mod), C, mod) << " " << (A % mod == 0 ? 0 : power(A, power(B, C, mod - 1), mod)) << endl; }