#include using namespace std; #if __has_include() #include using namespace atcoder; #endif // clang-format off struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(13); } }init; typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef pair pll; typedef vector> Graph; #define rep(i, x, limit) for (int i = (int)x; i < (int)limit; i++) #define REP(i, x, limit) for (int i = (int)x; i <= (int)limit; i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define el '\n' #define spa " " #define YES cout << "Yes" << el #define NO cout << "No" << el #define eps (1e-10) #define Equals(a,b) (fabs((a) - (b)) < eps ) const double pi = 3.141592653589793238; const int inf = 1073741823; const ll infl = 1LL << 60; //配列の要素を空白区切りで出力 template inline void print_vec(const vector& v) { if(v.empty()){ cout << "This vector is empty." << el; return; } for (int i = 0; i < v.size(); i++) { if(v[i]==inf || v[i]==infl) cout << 'x' << spa; else cout << v[i] << spa; } cout << el; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } // clang-format on typedef modint998244353 mint; //-------------------------------------------------------- int main() { ll n,k; cin >> n >> k; mint inv = mint(1)/k; mint ans = inv.pow(n) * mint(k-1) * n * k; cout << ans.val() << el; }