#include using namespace std; #include using mint = atcoder::modint998244353; int main() { int N, K; cin >> N >> K; cout << (mint(K - 1) * mint(N) / mint(K).pow(N - 1)).val() << endl; }