#include using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; ll modpow(ll x, ll n, ll mod) { if (x == 0) return 0; ll res = 1; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, c; scanf("%lld^%lld^%lld", &a, &b, &c); cout << modpow(modpow(a, b, MOD), c, MOD); cout << " "; cout << modpow(a % MOD, modpow(b, c, MOD - 1), MOD) << endl; return 0; }