#include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define ll long long int main() { ios::sync_with_stdio(0); cin.tie(0); int N, M; cin >> N >> M; vector> dp(N+1, vector(N+1, 0)); dp[0][0] = 1; for (int i=0;i 0 && j > 0) dp[i+1][j+1] += dp[i][j]*(mint(M-j).inv())*(M-j-1); } } cout << "dp: " << "\n"; for (int i=0;i<=N;i++) { for (int j=0;j<=N;j++) { cout << dp[i][j].val() << " "; } cout << "\n"; } mint ans = mint(M).pow(N); // cout << ans.val() << "\n"; for (int i=0;i<=N;i++) ans -= dp[N][i]; cout << ans.val() << "\n"; return 0; }