#include #include using namespace std; using mint = atcoder::modint998244353; mint res; int main() { long long n; int m; cin >> n >> m; vector pow_t(m + 1); for(int i = 0; i <= m; i++) pow_t[i] = mint(i).pow(n); for(int diff = 1; diff < m; diff++) { mint tmp = pow_t[diff + 1] - pow_t[diff] * 2 + pow_t[diff - 1]; res += tmp * diff * (m - diff); } res *= n; res *= m + 1; res /= 2; cout << res.val() << '\n'; }