#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

constexpr ll MOD = 998244353;
using mint = modint998244353;
istream &operator>>(istream &is, mint &m) {
  ll n;
  is >> n;
  m = n;
  return is;
}
ostream &operator<<(ostream &os, const mint &m) { return os << m.val(); }
mint operator^(const mint &x, const ll &n) { return x.pow(n); }
mint operator^=(mint &x, const ll &n) { return x = x.pow(n); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  mint k;
  cin >> n >> k;
  cout << k * (k - 1) * n / (k ^ n) << "\n";
}