#include <bits/stdc++.h> using namespace std; const int P = 998244353; int qpow(int b, int k) { int ret = 1; while(k > 0) { if(k & 1) ret = ret * (long long)b % P; b = (long long)b * b % P; k >>= 1; } return ret; } int main() { int n, k; cin >> n >> k; cout << n * (k - 1ll) * k % P * qpow(qpow(k, n), P - 2) % P; }