#include using namespace std; typedef long long ll; const ll MOD = 1000 * 1000 * 1000 + 7; ll pow_mod(ll a, ll n, ll mod) { if (n == 0) return 1; if (n % 2 == 0) { ll val = pow_mod(a, n / 2, mod); return (val * val) % mod; } else { return ((a % mod) * pow_mod(a, n - 1, mod)) % mod; } } int main() { ll A, B, C; scanf("%lld^%lld^%lld", &A, &B, &C); ll temp = pow_mod(A % MOD, B, MOD), ans1, ans2; ans1 = pow_mod(temp, C, MOD); if (A % MOD == 0) { ans2 = 0; } else { temp = pow_mod(B % (MOD - 1), C, MOD - 1); ans2 = pow_mod(A % MOD, temp, MOD); } printf("%lld %lld\n", ans1, ans2); return 0; }