#include #include #include #include #include #include using namespace std; using ll = long long; using pii = pair; using vi = vector; templateusing vv = vector>; #define in(v) v; cin >> v; // #define rep(i,n) for(int i=0;i<(n);++i) #define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c)) #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) for(int i=0;i<(n);++i) #define repi(i,a,b) for(int i=(a);i<(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define rrep(i,n) for(int i=(n);i>=0;--i) const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1}; templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(bostream& operator<<(ostream& os,const vector& vec){os<<"{";for(size_t i=0;i&v){for(size_t i=0;iostream& operator<<(ostream& os,const pair& rhs){os<<"("< void debug(const First& first) {cerr< void debug(const First& first, const Rest&... rest) {cerr< struct MInt { long long val; MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; } MInt operator-() const { return MInt(-val); } MInt operator+(const MInt& n) const { return MInt(val) += n; } MInt operator-(const MInt& n) const { return MInt(val) -= n; } MInt operator*(const MInt& n) const { return MInt(val) *= n; } MInt operator/(const MInt& n) const { return MInt(val) /= n; } MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; } MInt& operator-=(const MInt& n) { val = (MOD + val - n.val) % MOD; return *this; } MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; } MInt& operator/=(const MInt& n) { val = (*this * n.inv()).val; return *this; } bool operator==(const MInt& n) { return val == n.val; } bool operator!=(const MInt& n) { return val != n.val; } MInt pow(ll n) const { MInt pow = val, ans = 1; for (ll p = n; p > 0; p >>= 1) { if (p & 1) ans *= pow; pow *= pow; } return ans; } MInt inv() const { return pow(MOD-2); } friend ostream& operator<<(ostream& os, const MInt& n) { os<>(istream& os, MInt& n) { os>>n.val; return os; } }; const int MOD = 1e9+7; using mint = MInt; using mint2 = MInt<1000000006>; int main() { ll A, B, C; if (scanf("%lld^%lld^%lld", &A, &B, &C)) {} mint a = A; mint2 b = B; printf("%lld %lld\n", (a.pow(B)).pow(C).val, a.pow(b.pow(C).val).val); return 0; }