#include "bits/stdc++.h" #include<vector> #include<iostream> #include<queue> #include<algorithm> #include<map> #include<set> #include<iomanip> #include<assert.h> #include<unordered_map> #include<unordered_set> #include<string> #include<stack> #include<complex> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps=1e-9; #define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl; template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){ os << "( " << v.first << ", " << v.second << ")"; return os; } template<class T> ostream& operator <<(ostream &os, const vector<T> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template<class T> ostream& operator <<(ostream &os, const set<T> &v){ int i=0; for(auto it:v){ if(i > 0){os << ' ';} os << it; i++; } return os; } using ll=long long ; const ll mod=129402307; vector<int>modv{1,2,9,4,0,2,3,0,6}; vector<int>modv2{1,2,9,4,0,2,3,0,7}; vector<int>solve(vector<int>l,vector<int>r){ swap(l,r); for(int i=0;i<=int(r.size())-int(l.size());++i){ while(true){ bool ok=true; if(i&&r[i-1]){ }else{ for(int j=0;j<l.size();++j){ if(l[j]<r[i+j])ok=true; else if(l[j]>r[i+j])ok=false; } } if(ok){ for(int j=0;j<l.size();++j){ r[i+j]-=l[j]; } for(int j=l.size()-1;j>=0;--j){ if(r[i+j]<0){ r[i+j]+=10; assert(i+j>0); r[i+j-1]--; } } }else{ break; } } } if(r.size()<l.size())return r; return vector<int>(r.end()-l.size(),r.end()); } ll mod_pow(ll a, ll b){ if(b==0)return 1; else{ ll xx=mod_pow(a,b/2); xx*=xx; xx%=mod; if(b%2){ xx*=a; xx%=mod; } return xx; } } int main() { ios::sync_with_stdio(false); string N,M;cin>>N>>M; vector<int>nv(N.size()),mv(M.size()); for(int i=0;i<N.size();++i)nv[i]=N[i]-'0'; for(int i=0;i<M.size();++i)mv[i]=M[i]-'0'; nv=solve(nv,modv2); mv=solve(mv,modv); ll nn=0,mm=0; for(int i=0;i<nv.size();++i){ nn*=10; nn+=nv[i]; } for(int i=0;i<mv.size();++i){ mm*=10; mm+=mv[i]; } WHATS(nn) WHATS(mm) ll answer=mod_pow(nn,mm); cout<<answer<<endl; return 0; }