n,m = map(int, input().split()) p = 998244353 v = pow(m, n, (m+1)*p) if n%2==1: v -= m; else: v += m; v %= (m+1)*p v //= (m+1) v %= p print(v)