N, M = map(int, input().split()) mod = 998244353 ans = 0 coef = [0] * (M + 1) for i in range(1, M + 1): coef[i] = pow(i, N - 1, mod) for i in range(1, M + 1): ans += i * (i*(i+1)//2 * coef[i] * N) ans -= i * (i*(i-1)//2 * coef[i-1] * N) ans += i * ((M*(M+1)//2-i*(i+1)//2) * coef[M-i] * N) ans -= i * ((M*(M+1)//2-i*(i-1)//2) * coef[M-i+1] * N) ans %= mod print(ans)