struct ModNum
{
#define TA template<typename T,typename... Args>
#define TT template<typename T>
struct fastmod
{
using u128=__uint128_t; using u64=uint64_t; using u32=signed;
u32 f,l; u64 m,d;
fastmod(u64 D=998244353):d(D)
{
const u128 ONE=1;
l=64-__builtin_clzll(d-1);
u128 M=((ONE<<(64+l))+(ONE<<l))/d;
if(M<(ONE<<64)) f=1,m=M; else f=0,m=M-(ONE<<64);
}
inline friend u64 operator / (u64 x,const fastmod &y)
{
if(y.f) return u128(x)*y.m>>64>>y.l;
else return (((x-(u128(x)*y.m>>64))>>1)+(u128(x)*y.m>>64))>>(y.l-1);
}
inline friend u64 operator % (u64 x,const fastmod &y)
{
return x-x/y*y.d;
}
inline friend u64 operator + (u64 x,const fastmod &y) {return x+y.d;}
inline friend u64 operator - (u64 x,const fastmod &y) {return x-y.d;}
inline friend bool operator == (u64 x,const fastmod &y) {return x==y.d;}
inline friend bool operator > (u64 x,const fastmod &y) {return x>y.d;}
inline friend bool operator < (u64 x,const fastmod &y) {return x<y.d;}
inline friend bool operator >= (u64 x,const fastmod &y) {return x>y.d||x==y.d;}
inline friend bool operator <= (u64 x,const fastmod &y) {return x<y.d||x==y.d;}
};
fastmod Mod;
inline void ChangeMod(int MOD){Mod=MOD;}
TT inline void Madd(T &a,T b) {a=a+b>=Mod?a+b-Mod:a+b;}
TT inline void Mdel(T &a,T b) {a=a-b<0?a-b+Mod:a-b;}
TT inline void Mmul(T &a,T b) {a=a*b%Mod;}
TT inline void Mmod(T &a) {a=(a%Mod+Mod)%Mod;}
TT inline T Cadd(T a,T b) {return a+b>=Mod?a+b-Mod:a+b;}
TT inline T Cdel(T a,T b) {return a-b<0?a-b+Mod:a-b;}
TT inline T Cmul(T a,T b) {return a*b%Mod;}
TT inline T Cmod(T a) {return (a%Mod+Mod)%Mod;}
TA inline void Madd(T &a,T b,Args... args) {Madd(a,Cadd(b,args...));}
TA inline void Mdel(T &a,T b,Args... args) {Mdel(a,Cadd(b,args...));}
TA inline void Mmul(T &a,T b,Args... args) {Mmul(a,Cmul(b,args...));}
TA inline T Cadd(T a,T b,Args... args) {return Cadd(Cadd(a,b),args...);}
TA inline T Cdel(T a,T b,Args... args) {return Cdel(Cdel(a,b),args...);}
TA inline T Cmul(T a,T b,Args... args) {return Cmul(Cmul(a,b),args...);}
TT inline T qpow(T a,T b) {int res=1; while(b) {if(b&1) Mmul(res,a); Mmul(a,a); b>>=1;} return res;}
TT inline T qmul(T a,T b) {int res=0; while(b) {if(b&1) Madd(res,a); Madd(a,a); b>>=1;} return res;}
TT inline T spow(T a,T b) {int res=1; while(b) {if(b&1) res=qmul(res,a); a=qmul(a,a); b>>=1;} return res;}
TT inline T Ginv(T x) {return qpow(x,(T)(Mod.d-2));}
#undef TT
#undef TA
};