#ifndef call_from_test #include using namespace std; #endif //BEGIN CUT HERE // construct a charasteristic equation from sequence template vector berlekamp_massey(vector &as){ using Poly = vector; int n=as.size(); Poly bs({-T(1)}),cs({-T(1)}); T y(1); for(int ed=1;ed<=n;ed++){ int l=cs.size(),m=bs.size(); T x(0); for(int i=0;i using namespace std; #endif //BEGIN CUT HERE template struct Mint{ 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 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;} bool operator <(const Mint a)const{return v constexpr T Mint::mod; template ostream& operator<<(ostream &os,Mint m){os<>h>>w>>k; using M = Mint; M ans{0}; for(int d=1;d using namespace std; #endif //BEGIN CUT HERE struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; //END CUT HERE #ifndef call_from_test signed main(){ return 0; } #endif #undef call_from_test signed YUKI_980(){ using M = Mint; int p; cin>>p; const int n = 100; vector as(n); as[0]=M(0); as[1]=M(0); as[2]=M(1); for(int i=3;i bs(n,M(0)); for(int s=0;s dp(MAX,0); for(int i=0;i>q; for(int i=0;i>k; cout<