#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; typedef unsigned long long ull; class Bignum{ public: Bignum(){} Bignum(string s){ for(int i=0;i=0;i--){ if(d[i]!=0) break; d.pop_back(); } return *this; } int operator[](int i){ return i>=d.size()?0:d[i]; } int size(){ return normalize(),d.size(); } void toZero(){ d.clear(); d.push_front(0); } void toOne(){ d.clear(); d.push_front(1); } Bignum &inc(){ Bignum one("1"); return operator+=(one); } Bignum &operator+=(Bignum n){ int l=max(size(),n.size()); d.resize(l+1,0); for(int c=0,i=0;i<=l;i++) d[i]=(c=d[i]+n[i]+c/10)%10; return normalize(); } Bignum &operator-=(Bignum n){ //assert(size()>=n.size()); for(int c=0,i=0;i=0;i--) d[i]=(c=c%n*10+d[i])/n; return c%n; } Bignum &operator<<=(int n){ for(int i=0;i(Bignum n){ if(size()!=n.size()) return size()>n.size(); for(int i=size()-1;i>=0;i--) if(d[i]!=n[i]) return d[i]>n[i]; return false; } ll toNum(){ ll ret = 0; for (int i=d.size()-1;i>=0;i--) ret = ret*10LL + d[i]; return ret; } deque d; }; pair ldiv(Bignum a, Bignum b) { Bignum ret; for(int i=a.size()-1;i>=0;i--){ int n; for(n=1;n<10;n++) if(((b*n)<a) break; a-=(b*(n-1))<=0;i--) os<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; Bignum N(sN); Bignum M(sM); Bignum P("129402307"); pair res1 = ldiv(N, P); pair res2 = ldiv(M, P-Bignum("1")); ll pn = res1.second.toNum(); ll pm = res2.second.toNum(); cout << mod_pow(pn, pm, 129402307LL) << endl; return 0; }