#include #if __has_include() #include #endif using namespace std; #define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__) #define fo(i,...) for(auto[i,i##stop,i##step]=for_range(0,__VA_ARGS__);i(1,__VA_ARGS__);i>=i##stop;i+=i##step) #define fe(a,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):a) #define defpp templatevoid pp(const auto&...a){[[maybe_unused]]const char*c="";((o<(a...);} #define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{ #define use_ml998244353 using ml=atcoder::modint998244353; namespace my{ auto&operator<<(ostream&o,const atcoder::modint998244353&x){return o<<(int)x.val();} void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<concept modulary=requires(T t){t.mod();}; templateconstexpr auto for_range(T s,T b){T a=0;if(s)swap(a,b);return array{a-s,b,1-s*2};} templateconstexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};} void lin(auto&...a){(cin>>...>>a);} templateusing pack_back_t=tuple_element_t>; } namespace my{ templateconcept vectorial=is_base_of_v::value_type>,remove_cvref_t>; templatestruct vec; templatestruct hvec_helper{using type=vec::type>;}; templatestruct hvec_helper<0,T>{using type=T;}; templateusing hvec=hvec_helper::type; templatestruct vec:vector{ using vector::vector; ll size()const{return vector::size();} vec mobius()const{vec v=*this;if constexpr(vectorial){ }of(i,v.size()-1)v[i+1]-=v[i];return v;} }; templaterequires(sizeof...(A)>=2)vec(const A&...a)->vec>>; } namespace my{ templateT fac(ll n){static vecv{1};if(ll m=v.size();m<=n){v.resize(n+1);fo(i,m,n+1)v[i]=v[i-1]*i;}return v[n];} templateT fac_inv(ll n){static vecv{1};if(ll m=v.size();m<=n){v.resize(n+1);v[n]=fac(n).inv();of(i,n,m)v[i]=v[i+1]*(i+1);}return v[n];} templateT comb(ll n,ll k){ if(n<0||k<0||n)return fac(n)*fac_inv(k)*fac_inv(n-k); else { } } } namespace my{entry void main(){ LL(N,M); use_ml998244353 // 2番目に大きい数=N-1番目に小さい数 vec cnt(M+1,ml{}); fo(i,1,M+1){ // N-1番目に小さい数がi以下であるものの個数. fo(t,N-1,N+1){ cnt[i]+=comb(N,t)*ml(i).pow(t)*ml(M-i).pow(N-t); } } cnt=cnt.mobius(); ml ans=0; fo(i,1,M+1)ans+=i*cnt[i]; pp(ans); }}