#include using namespace std; using Int = long long; const char newl = '\n'; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout< vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } 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 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 decltype(auto) naive(){ using Poly = vector; auto conv=[](Poly as, Poly bs){ Poly cs(as.size()+bs.size()-1,0); for(Int i=0;i<(Int)as.size();i++) for(Int j=0;j<(Int)bs.size();j++) cs[i+j]+=as[i]*bs[j]; return cs; }; return +conv; } // Find k-th term of linear recurrence // execute `conv` O(\log k) times template struct BostanMori{ using Poly = vector; using Conv = function; Conv conv; BostanMori(Conv conv_):conv(conv_){} Poly sub(Poly as,Int odd){ Poly bs((as.size()+!odd)/2); for(Int i=odd;i<(Int)as.size();i+=2) bs[i/2]=as[i]; return bs; } // as: initial values // cs: monic polynomial T build(long long k,Poly as,Poly cs){ reverse(cs.begin(),cs.end()); assert(cs[0]==T(1)); Int n=cs.size()-1; as.resize(n,0); Poly bs=conv(as,cs); bs.resize(n); while(k){ Poly ds(cs); for(Int i=1;i<(Int)ds.size();i+=2) ds[i]=-ds[i]; bs=sub(conv(bs,ds),k&1); cs=sub(conv(cs,ds),0); k>>=1; } return bs[0]; } }; //INSERT ABOVE HERE using M = Mint; const Int N = 2000; M dp[N+1][101]={}; signed main(){ cin.tie(0); ios::sync_with_stdio(0); Int n,m; cin>>n>>m; if(m==1) drop(0); if(m==2) drop(n&1); assert(m<=20); vector as; dp[0][0]=1; for(Int l=0;l0) as.emplace_back(sum); } BostanMori bm(naive()); cout<