#include #include using namespace std; using namespace atcoder; using ll = long long; #define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i) #define rep(i, n) reps(i, 0, n) #define all(a) (a).begin(), (a).end(); //なんかstd::vectorの挙動を修正できるやつ /* alias */ using ull = unsigned long long; using ll = long long; using vi = vector; using vl = vector; using vll = vector; using vvi = vector; using vvl = vector; using vvll = vector; using vs = vector; using pii = pair; ll mod = 998244353; ll modpow(ll x, ll y) { ll res = 1; rep(i, y) { res = (res * x) % mod; } return res; } int main() { ll n, k; cin >> n >> k; ll p = inv_mod(modpow(k, n), mod) % mod; ll cnt = ((n * k * k * (k - 1) / 2) + mod) % mod; ll ans = ((cnt * p) + mod) % mod; cout << ans << endl; }