#include using namespace std; using ll = long long; constexpr int P = 998244353; template struct ModInt { const static int mod = T; int x; ModInt(int x = 0) : x(x % mod) {} int val() { return x; } constexpr int moded (int x) const { if (x < 0) { x += P; } if (x >= P) { x -= P; } return x; } ModInt operator + (const ModInt &a) const { int x0 = x; x0 += a.x; return ModInt(x0); } ModInt operator - (const ModInt &a) const { int x0 = x - a.x; return ModInt(x0 < mod ? x0 + mod : x0); } ModInt operator * (const ModInt &a) const { return ModInt(1LL * x * a.x % mod); } ModInt operator / (const ModInt &a) const { return *this * a.inv(); } void operator += (const ModInt &a) { x = moded(x + a.x); if (x >= mod) x -= mod; } void operator -= (const ModInt &a) { x -= a.x; if (x < 0) x += mod; } void operator *= (const ModInt &a) { x = 1LL * x * a.x % mod; } void operator /= (const ModInt &a) { *this = *this / a; } friend ostream &operator<<(ostream &os, const ModInt &a) { return os << a.x;} ModInt pow(int64_t n) const { ModInt res(1), mul(x); while(n){ if (n & 1) res *= mul; mul *= mul; n >>= 1; } return res; } ModInt inv() const { int a = x, b = mod, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } if (u < 0) u += mod; return u; } }; typedef ModInt

mint; // mod1 || mod2 void Solve() { int n, k; cin >> n >> k; mint ans = k - 1; for (int i = 1; i <= n - 1; i++) { ans = ans / k; } cout << ans * n << '\n'; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; //cin >> tt; while (tt--) Solve(); return 0; }