#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; ll strmod(const string& n, const ll& m){ ll ret = 0; int j = 0; while(true){ if(ret >= m) ret%=m; if(j >= n.size()) break; ret = ret*10 + (n[j]-'0'); j++; } return ret; } ll mod_pow(ll x, ll n, ll mod){ ll res = 1; while(n>0){ if(n&1) res = res*x%mod; x = x*x%mod; n >>= 1; } return res; } int main(){ ios::sync_with_stdio(false); string sN, sM; cin >> sN >> sM; ll res1 = strmod(sN, 129402307LL); ll res2 = strmod(sM, 129402306LL); cout << mod_pow(res1, res2, 129402307LL) << endl; return 0; }