#include #include #include #include #include #include #include #include using namespace std; #define GET_ARG(a,b,c,F,...) F #define REP3(i,s,e) for (i = s; i <= e; i++) #define REP2(i,n) REP3 (i,0,(int)(n)-1) #define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__) #define RREP3(i,s,e) for (i = s; i >= e; i--) #define RREP2(i,n) RREP3 (i,(int)(n)-1,0) #define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__) #define DEBUG(x) cerr << #x ": " << x << endl typedef long long ll; constexpr int INF = 1e8; constexpr int MOD = 1e9+7; constexpr int ESP = 1e-9; constexpr double PI = acos(-1); ll modpow(ll x, ll n, int mod) { x %= mod; n %= mod-1; if (x == 0) return 0; ll ret = 1; while (n) { if (n % 2) ret = ret * x % mod; x = x * x % mod; n /= 2; } return ret; } int main(void) { ll a, b, c; scanf("%lld^%lld^%lld",&a,&b,&c); int ans1, ans2; ans1 = modpow(a,b%(MOD-1)*(c%(MOD-1)),MOD); int x = b%2; int y = modpow(b,c,MOD/2); ans2 = modpow(a,2*y*modpow(2,MOD/2-2,MOD/2)+MOD/2*x,MOD); printf("%d %d",ans1,ans2); return 0; }