#ifndef call_from_test #include using namespace std; #endif // https://noshi91.hatenablog.com/entry/2019/09/23/002445 //BEGIN CUT HERE // O(n \log \log n) namespace DivisorTransform{ template void inc(vector &as,F f){ assert(as[0]==T(0)); int n=as.size(); vector sieve(n,true); for(int p=2;p void dec(vector &as,F f){ assert(as[0]==T(0)); int n=as.size(); vector sieve(n,true); for(int p=2;p void zeta(vector &as){ auto f=[](T &lo,T &hi){lo+=hi;}; DivisorTransform::inc(as,f); } template void moebius(vector &as){ auto f=[](T &lo,T &hi){lo-=hi;}; DivisorTransform::dec(as,f); } } namespace LCMConvolution{ template void zeta(vector &as){ auto f=[](T &lo,T &hi){hi+=lo;}; DivisorTransform::dec(as,f); } template void moebius(vector &as){ auto f=[](T &lo,T &hi){hi-=lo;}; DivisorTransform::inc(as,f); } } //END CUT HERE #ifndef call_from_test template struct Mint{ inline static constexpr T mod = MOD; T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0) v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;} Mint operator-(Mint a) const{return Mint(v)-=a;} Mint operator*(Mint a) const{return Mint(v)*=a;} Mint operator/(Mint a) const{return Mint(v)/=a;} Mint operator+() const{return *this;} Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i ostream& operator<<(ostream &os,Mint m){os<; vector ys(MAX,0),xs(MAX,0); int h,w; cin>>h>>w; for(int i=1;i