#include<iostream> #include<cstdio> #define ll long long usingnamespacestd;
constint p = 9901;
ll mul(ll x, ll n, ll p){ ll s = 0; for (; n; n >>= 1) { if (n & 1) s = (s + x) % p; x = (x + x) % p; } return s; }
ll pow_mod(ll x, ll n, ll p){ ll s = 1; for (; n; n >>= 1) { if (n & 1) s = mul(s, x, p); x = mul(x, x, p); } return s; }
int n, k;
ll a[1010], cnt, b[1010];
ll ans;
voidinit(){ cnt = 0; ans = 1; fill(a, a + 1010, 0); }
voidwork(){ init(); for (int i = 2; i * i <= n; ++i) { if (n % i) continue; b[++cnt] = i; while (n % i == 0) n /= i, ++a[cnt]; a[cnt] *= k; } if (n > 1) a[++cnt] = k, b[cnt] = n; for (int i = 1; i <= cnt; ++i) { ll t = p * (b[i] - 1); ans = ans * (pow_mod(b[i], a[i] + 1, t) + t - 1) % t / (b[i] - 1) % p; } cout << ans << "\n"; }
intmain(){ while (cin >> n >> k) work(); return0; }
#include<iostream> #include<cstdio> #define ll long long usingnamespacestd;
constint p = 9901;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1) { if (n & 1) s = s * x % p; x = x * x % p; } return s; }
int n, k;
ll a[1010], cnt, b[1010];
intsolve(int a, int n){ if (n == 0) return1; if (n & 1) return solve(a, n / 2) * (1 + pow_mod(a, n / 2 + 1)) % p; elsereturn (solve(a, n / 2 - 1) * (1 + pow_mod(a, n / 2 + 1)) + pow_mod(a, n / 2)) % p; }
ll ans;
voidinit(){ cnt = 0; ans = 1; fill(a, a + 1010, 0); }
voidwork(){ init(); for (int i = 2; i * i <= n; ++i) { if (n % i) continue; b[++cnt] = i; while (n % i == 0) n /= i, ++a[cnt]; a[cnt] *= k; } if (n > 1) a[++cnt] = k, b[cnt] = n; for (int i = 1; i <= cnt; ++i) ans = ans * solve(b[i], a[i]) % p; cout << ans << "\n"; }
intmain(){ while (cin >> n >> k) work(); return0; }