#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } template struct ModInt{ long long x; ModInt():x(0){} ModInt(long long y):x(y>=0?y%Mod:(Mod-(-y)%Mod)%Mod){} ModInt &operator+=(const ModInt &p){ if((x+=p.x)>=Mod) x-=Mod; return *this; } ModInt &operator-=(const ModInt &p){ if((x+=Mod-p.x)>=Mod)x-=Mod; return *this; } ModInt &operator*=(const ModInt &p){ x=(int)(1ll*x*p.x%Mod); return *this; } ModInt &operator/=(const ModInt &p){ (*this)*=p.inverse(); return *this; } ModInt operator-()const{return ModInt(-x);} ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;} ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;} ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;} ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;} bool operator==(const ModInt &p)const{return x==p.x;} bool operator!=(const ModInt &p)const{return x!=p.x;} ModInt inverse()const{ int a=x,b=Mod,u=1,v=0,t; while(b>0){ t=a/b; swap(a-=t*b,b);swap(u-=t*v,v); } return ModInt(u); } ModInt pow(long long n)const{ ModInt ret(1),mul(x); while(n>0){ if(n&1) ret*=mul; mul*=mul;n>>=1; } return ret; } friend ostream &operator<<(ostream &os,const ModInt &p){return os<>(istream &is,ModInt &a){long long t;is>>t;a=ModInt(t);return (is);} static int get_mod(){return Mod;} }; using mint=ModInt; template struct comcalc{ vector fact,finv,inv; comcalc():fact(MAX),finv(MAX),inv(MAX){ fact[0]=mint(1),fact[1]=mint(1),finv[0]=mint(1),finv[1]=mint(1),inv[1]=mint(1); for(int i=2;ir)return mint(0); mint ret=mint(r+1)*com(n+r+1,r+1)-mint(l)*com(l+n,l); ret/=mint(n+1); return ret; } }; mint pow_mod(mint x,ll n){ return x.pow(n); } mint inv_mod(mint x){ return x.inverse(); } // O(n) mint fact_mod(ll n){ mint ret=1; for(int i=2;i<=n;i++) ret*=mint(i); return ret; } // O(r) mint comb_mod(ll n,ll r){ if(r>n-r) r=n-r; if(r==0) return 1; mint a=1,b=mint(fact_mod(r)).inverse(); for(int i=0;i; template struct FormalPowerSeries:vector{ using vector::vector; using P=FormalPowerSeries; using MULT=function; static MULT &get_mult(){static MULT mult=nullptr;return mult;} static void set_mult(MULT f){get_mult()=f;} void shrink(){while(this->size() and this->back()==T(0)) this->pop_back();} P pre(int sz)const{return P(begin(*this),begin(*this)+min((int)this->size(),sz));} P operator+(const P &rhs)const{return P(*this)+=rhs;} P operator+(const T &rhs)const{return P(*this)+=rhs;} P operator-(const P &rhs)const{return P(*this)-=rhs;} P operator-(const T &rhs)const{return P(*this)-=rhs;} P operator*(const P &rhs)const{return P(*this)*=rhs;} P operator*(const T &rhs)const{return P(*this)*=rhs;} P operator/(const P &rhs)const{return P(*this)/=rhs;} P operator%(const P &rhs)const{return P(*this)%=rhs;} P &operator+=(const P &rhs){ if(rhs.size()>this->size()) this->resize(rhs.size()); for(int i=0;i<(int)rhs.size();i++) (*this)[i]+=rhs[i]; return (*this); } P &operator+=(const T &rhs){ if(this->empty()) this->resize(1); (*this)[0]+=rhs; return (*this); } P &operator-=(const P &rhs){ if(rhs.size()>this->size()) this->resize(rhs.size()); for(int i=0;i<(int)rhs.size();i++) (*this)[i]-=rhs[i]; shrink(); return (*this); } P &operator-=(const T &rhs){ if(this->empty()) this->resize(1); (*this)[0]-=rhs; shrink(); return (*this); } P &operator*=(const T &rhs){ const int n=(int)this->size(); for(int i=0;iempty() or rhs.empty()){ this->clear(); return (*this); } assert(get_mult()!=nullptr); return (*this)=get_mult()(*this,rhs); } P &operator%=(const P &rhs){return (*this)-=(*this)/rhs*rhs;} P operator-()const{ P ret(this->size()); for(int i=0;i<(int)this->size();i++) ret[i]=-(*this)[i]; return ret; } P &operator/=(const P &rhs){ if(this->size()clear(); return (*this); } int n=(int)this->size()-rhs.size()+1; return (*this)=(rev().pre(n)*rhs.rev().inv(n)); } P operator>>(int sz)const{ if((int)this->size()<=sz) return {}; P ret(*this); ret.erase(ret.begin(),ret.begin()+sz); return ret; } P operator<<(int sz)const{ P ret(*this); ret.insert(ret.begin(),sz,T(0)); return ret; } P rev(int deg=-1)const{ P ret(*this); if(deg!=-1) ret.resize(deg,T(0)); reverse(begin(ret),end(ret)); return ret; } // 微分 P diff()const{ const int n=(int)this->size(); P ret(max(0,n-1)); for(int i=1;isize(); P ret(n+1); ret[0]=T(0); for(int i=0;isize(); if(deg==-1) deg=n; P ret({T(1)/(*this)[0]}); for(int i=1;isize(); if(deg==-1) deg=n; return (this->diff()*this->inv(deg)).pre(deg-1).integral(); } // ? P exp(int deg=-1)const{ assert((*this)[0]==T(0)); const int n=(int)this->size(); if(deg==-1) deg=n; P ret({T(1)}); for(int i=1;isize(); if(deg==-1) deg=n; for(int i=0;i>i).log()*k).exp()*((*this)[i].pow(k)); if(i*k>deg) return P(deg,T(0)); ret=(ret<<(i*k)).pre(deg); if((int)ret.size()>=1; if((int)ret.size()>deg) ret.resize(deg); if((int)b.size()>deg) b.resize(deg); } return ret; } // [l,r) k個飛び P slice(int l,int r,int k=1){ P ret; for(int i=l;i d次元,multiplyの計算量) return : [x^k] (*this) / q */ T nth_term(P q,ll k){ if(k==0) return (*this)[0]/q[0]; P p(*this),q_=q; for(int i=1;i<(int)q_.size();i+=2) q_[i]*=-1; q*=q_;p*=q_;// qは奇数項が消える return p.slice(k%2,p.size(),2).nth_term(q.slice(0,q.size(),2),k/2); } }; using FPS=FormalPowerSeries; auto multiply_naive(const FPS::P &lhs,const FPS::P &rhs){ assert(!lhs.empty() and !rhs.empty()); auto ret=FPS(int(lhs.size())+int(rhs.size())-1); rep(i,(int)lhs.size())rep(j,(int)rhs.size()) ret[i+j]+=lhs[i]*rhs[j]; return ret; } signed main(){ FPS::set_mult(multiply_naive); cominit F; int n,k;cin>>n>>k; rep(i,n){int a;cin>>a;} FPS P{1}; rep(i,n) P-=(P<<(i+1)); mint res=0; rep(i,k+1){ res+=P[i]*F.com(k+n-i,n); } cout<