#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b 0){ if(x & 1) res = (res * a) % mod; a = (a * a) % mod; x >>= 1; } return res; } vector> mul(vector> A, vector> B){ vector> C(2,vector(2,0)); rep(i,2) rep(j,2) rep(k,2){ C[i][j] += A[i][k] * B[k][j] % (mod-1); C[i][j] %= (mod-1); } return C; } vector> P(vector> A,ll K){ vector> R = {{1,0},{0,1}}; while(K>0){ if(K&1) R = mul(R,A); A = mul(A,A); K>>=1; } return R; } int main(){ const int max_N = 10000000; vector prime(max_N+1, 0); prime[0] = prime[1] = 1; for(int i=2; i <= max_N; i++){ if(prime[i]==0){ for(int j=i*2; j <= max_N; j+=i){ if(prime[j]==0) prime[j]=i; } prime[i]=i; } } ll N,K; cin >> N >> K; map F; while(N>1){ int f = prime[N]; F[f]++; N/=f; } while(1){ map G; for(auto f:F){ int n = f.first + 1; map tmp; while(n>1){ int d = prime[n]; tmp[d]++; n/=d; } for(auto t:tmp){ G[t.first] += t.second * f.second % (mod-1); G[t.first] %= (mod-1); } } K--; swap(F,G); if(K==0) break; if(sz(F)==2 && F.count(2) && F.count(3)) break; if(sz(F)==1 && (F.count(2) || F.count(3))) break; } if(K){ vector> A = {{0,2},{1,0}}; auto AK = P(A,K); map G; G[2] = (AK[0][0]*F[2]+AK[0][1]*F[3])%(mod-1); G[3] = (AK[1][0]*F[2]+AK[1][1]*F[3])%(mod-1); F = G; } ll ans = 1; for(auto f:F){ ans *= mpow(f.first,f.second) % mod; ans %= mod; } cout << ans << '\n'; return 0; };