#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define syosu(x) fixed< P; typedef pair pdd; typedef pair pll; typedef vector vi; typedef vector vvi; typedef vector vd; typedef vector vvd; typedef vector vl; typedef vector vvl; typedef vector vc; typedef vector vvc; typedef vector vs; typedef vector vb; typedef vector vvb; typedef vector

vp; typedef vector vvp; typedef vector vpll; typedef pair pip; typedef vector vip; const int inf=1<<29; const ll INF=1ll<<58; const double pi=acos(-1); const double eps=1e-7; const ll mod=1e9+7; const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; ll Pow_mod(ll n,ll p){ ll r=1; for(;p>0;p>>=1){ if(p&1) r=(r*n)%mod; n=(n*n)%mod; } return r; } vl fact(3000); ll Fact(ll n){ if(fact[n]) return fact[n]; if(!n) return fact[n]=1; return fact[n]=Fact(n-1)*n%mod; } ll Div(ll n,ll m){ return n*Pow_mod(m,mod-2)%mod; } ll nCk(ll n,ll k){ return Div(Fact(n),Fact(n-k)*Fact(k)%mod); } ll nPk(ll n,ll k){ return Div(Fact(n),Fact(n-k)); } int n; class Trie{ private: const int MAX=100; int ID=1; vvl date; vl a,u,dp; void Fix(vl& dp,ll h,int v){ if(u[v]==1){ dp[1]=1; return; } for(int i=1;i<=u[v];i++) (dp[i]+=nPk(u[v],i)%mod*h)%=mod; } void dfs(int v,vl& dp,ll& h){ if(a[v]==1){ for(int i=0;i<27;i++) if(date[v][i]!=-1) dfs(date[v][i],dp,h); h++; return; } int S; bool b=1; for(int i=0;i<27;i++){ int v_=date[v][i]; if(v_!=-1){ vl DP(n+1),dp_(n+1); ll H=0; dfs(v_,DP,H); /* if(v==0){ cout<<'B'<>n; Trie trie; for(int i=0;i>s; s+="{"; trie.Update(s); } trie.Solve(); }