#include using namespace std; #define all(vec) vec.begin(),vec.end() typedef long long int ll; typedef pair P; const ll MOD=1000000007; const ll INF=1000000010; const ll LINF=4000000000000000010LL; const int MAX=310; const double EPS=1e-3; int dx[4]={0,1,0,1}; int dy[4]={0,0,1,1}; ll mod_pow(ll x,ll p,ll mod){ if(p==0)return 1; ll res=mod_pow((x*x)%mod,p/2,mod); if(p%2)(res*=x)%=mod; return res; } int main(){ ll a,b,c; scanf("%lld^%lld^%lld",&a,&b,&c); ll ansa=mod_pow(mod_pow(a,b,MOD),c,MOD); ll ansb=mod_pow(a,mod_pow(b,c,MOD),MOD); cout<