#include using namespace std; using ll = long long; template using min_priority_queue = priority_queue, greater>; using pii = pair; using pll = pair; using Graph = vector>; const ll INF = 1LL << 60; const ll Z = 1000000000 + 7; template void chmax(T& a, T b) { if (b > a) a = b; } template void chmin(T& a, T b) { if (b < a) a = b; } template std::ostream& operator<<(std::ostream& os, const pair& x) noexcept { return os << "(" << x.first << ", " << x.second << ")"; } template void print_vector(vector a) { cout << '['; for (int i = 0; i < a.size(); i++) { cout << a[i]; if (i != a.size() - 1) { cout << ", "; } } cout << ']' << endl; } template class ModInt { public: constexpr ModInt() { val = 0; } constexpr ModInt(ll v) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr ll getval() const noexcept { return val; } constexpr ModInt operator-() const noexcept { if (val == 0) return 0; return MOD - val; } constexpr ModInt operator+(const ModInt& r) const noexcept { return ModInt(*this) += r; } constexpr ModInt operator-(const ModInt& r) const noexcept { return ModInt(*this) -= r; } constexpr ModInt operator*(const ModInt& r) const noexcept { return ModInt(*this) *= r; } constexpr ModInt operator/(const ModInt& r) const noexcept { return ModInt(*this) /= r; } constexpr ModInt& operator+=(const ModInt& r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr ModInt& operator-=(const ModInt& r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr ModInt& operator*=(const ModInt& r) noexcept { val = val * r.val % MOD; return *this; } constexpr ModInt& operator/=(const ModInt& r) noexcept { ll a = r.val, b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const ModInt& r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const ModInt& r) const noexcept { return this->val != r.val; } friend constexpr std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; } // n乗 を MOD で割った余り constexpr ModInt pow(ll n) noexcept { if (n == 0) return 1; auto t = this->pow(n / 2); t = t * t; if (n & 1) t = t * val; return t; } // 逆元 constexpr ModInt inv() noexcept { ModInt one = 1; return one / *this; } ModInt& operator=(ll v) noexcept { val = v % MOD; return *this; } ModInt& operator=(const ModInt& v) noexcept { val = v.val % MOD; return *this; } private: ll val; }; using mint = ModInt; ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll ceilll(ll x, ll y) { return (x + y - 1) / y; } ll mod(ll x, ll y) { return (x + 10000000) % y; } // 約数全列挙 vector all_divisors(ll K) { vector ret; for (ll i = 1; i * i <= K; i++) { if (K % i != 0) continue; ret.push_back(i); if (i * i != K) ret.push_back(K / i); } return ret; } // 素因数分解 vector> prime_factorize(ll N) { vector> res; for (ll a = 2; a * a <= N; ++a) { if (N % a != 0) continue; ll ex = 0; while (N % a == 0) { ++ex; N /= a; } res.push_back({a, ex}); } if (N != 1) res.push_back({N, 1}); return res; } class Eratosthenes { public: // コンストラクタ Eratosthenes(); Eratosthenes(int); // 高速素因数分解 vector factorize(int n) const; // 素数判定 bool is_prime(int n) const; // 約数の個数 int n_divisors(int n) const; private: std::vector _isprime; std::vector _minfactor; }; // コンストラクタ Eratosthenes::Eratosthenes() {} Eratosthenes::Eratosthenes(int N) { _isprime = std::vector(N + 1, true); _minfactor = std::vector(N + 1, -1); // 1 は予めふるい落としておく _isprime[1] = false; _minfactor[1] = 1; // 篩 for (int p = 2; p <= N; ++p) { // すでに合成数であるものはスキップする if (!_isprime[p]) continue; // p についての情報更新 _minfactor[p] = p; // p 以外の p の倍数から素数ラベルを剥奪 for (int q = p * 2; q <= N; q += p) { // q は合成数なのでふるい落とす _isprime[q] = false; // q は p で割り切れる旨を更新 if (_minfactor[q] == -1) _minfactor[q] = p; } } } vector Eratosthenes::factorize(int n) const { vector res; while (n > 1) { int p = _minfactor[n]; int exp = 0; // n で割り切れる限り割る while (_minfactor[n] == p) { n /= p; ++exp; } res.emplace_back(p, exp); } return res; } bool Eratosthenes::is_prime(int n) const { return _isprime[n]; } int Eratosthenes::n_divisors(int n) const { auto tmp = this->factorize(n); int ret = 1; for (auto& v : tmp) { ret *= v.second + 1; } return ret; } auto es = Eratosthenes(1000000); vector f(vector& pf) { unordered_map mp; for (auto& v : pf) { ll q = v.first + 1; auto x = es.factorize(q); for (auto& u : x) { mp[u.first] += v.second * u.second; } } vector ret; for (auto& v : mp) { ret.push_back({v.first, v.second}); } return ret; } // 2^a * 4^b の形になっているか bool is_2a3b(vector& pf) { if (pf.size() > 2) return false; for (auto& v : pf) { if (v.first != 2 && v.first != 3) return false; } return true; } ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } void solve() { ll N, K; cin >> N >> K; auto pf = prime_factorize(N); bool guchoku = false; if (guchoku) { // 愚直な実装 for (int i = 0; i < K; i++) { pf = f(pf); print_vector(pf); // if (i >= 100) break; } } else { // print_vector(pf); while (true) { if (K == 0) break; if (is_2a3b(pf)) break; pf = f(pf); // print_vector(pf); K--; } if (K > 0) { if (K % 2 == 0) { mint ret = 1; for (auto& v : pf) { ret *= modpow(v.first, modpow(2, K / 2, Z) * v.second, Z); } std::cout << ret << "\n"; return; } else { ll L = (K - 1) / 2; ll two_e, three_e; for (auto& v : pf) { if (v.first == 2) { two_e = v.second; } if (v.first == 3) { three_e = v.second; } } mint ret = 1; ret *= modpow(2, modpow(2, (L + 1), Z - 1) * three_e, Z); ret *= modpow(3, modpow(2, L, Z - 1) * two_e, Z); std::cout << ret << "\n"; return; } } } // print_vector(pf); mint ret = 1; for (auto& v : pf) { ret *= mint(v.first).pow(v.second); } std::cout << ret << "\n"; } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); int T = 1; while (T--) { solve(); } return 0; }