#include<cstdio>#include<cstring>#define mod 1000000007#define ll long longint m;
ll n;struct Matrix {
ll c[105][105];
Matrix (){memset( c,0,sizeof( c ));}
Matrix operator*(const Matrix &p )const{
Matrix ans;for(int i =1;i <= m;i ++)for(int j =1;j <= m;j ++)for(int k =1;k <= m;k ++)
ans.c[i][j]=( ans.c[i][j]+ c[i][k]* p.c[k][j]% mod )% mod;return ans;}}A, result;
Matrix qkpow( Matrix a, ll b ){
Matrix ans;for(int i =1;i <= m;i ++) ans.c[i][i]=1;while( b ){if( b &1) ans = ans * a;
a = a * a;
b >>=1;}return ans;}intmain(){scanf("%lld %d",&n,&m );for(int i =2;i <= m;i ++)
A.c[i][i -1]=1;
A.c[1][m]= A.c[m][m]=1;
result.c[1][m]=1;
result = result *qkpow( A, n );printf("%lld", result.c[1][m]);}
#include<cstdio>#include<cstring>#define ll long long#define mod 1000000007struct Matrix {int n, m;
ll c[6][6];voidclear(){
n = m =0;memset( c,0,sizeof( c ));}
Matrix operator*(const Matrix &p )const{
Matrix ans;
ans.clear();
ans.n = n, ans.m = p.m;for(int i =1;i <= n;i ++)for(int k =1;k <= m;k ++)for(int j =1;j <= p.m;j ++)
ans.c[i][j]=( ans.c[i][j]+ c[i][k]* p.c[k][j]%( mod -1))%( mod -1);return ans;}}v, p, w;
Matrix qkpow( Matrix x, ll y ){
Matrix ans;
ans.clear();
ans.n = x.n, ans.m = x.m;for(int i =1;i <= ans.n;i ++)
ans.c[i][i]=1;while( y ){if( y &1) ans = ans * x;
x = x * x, y >>=1;}return ans;}
ll qkpow( ll x, ll y ){
ll ans =1;while( y ){if( y &1) ans = ans * x % mod;
x = x * x % mod, y >>=1;}return ans;}
ll n, f1, f2, f3, c, result =1;intmain(){scanf("%lld %lld %lld %lld %lld",&n,&f1,&f2,&f3,&c );//c
w.clear(), v.clear();
w.n =5, w.m =1, w.c[5][1]=2;
v.n = v.m =5;
v.c[1][1]= v.c[1][2]= v.c[1][3]= v.c[1][4]= v.c[1][5]= v.c[2][1]= v.c[3][2]= v.c[4][4]= v.c[4][5]= v.c[5][5]=1;
v =qkpow( v, n -3);
w = v * w;
result = result *qkpow( c, w.c[1][1])% mod;
v.clear();
v.n = v.m =3;
v.c[1][1]= v.c[1][2]= v.c[1][3]= v.c[2][1]= v.c[3][2]=1;
v =qkpow( v, n -3);//f1
p.clear();
p.n =3, p.m =1;
p.c[3][1]=1;
p = v * p;
result = result *qkpow( f1, p.c[1][1])% mod;//f2
p.clear();
p.n =3, p.m =1;
p.c[2][1]=1;
p = v * p;
result = result *qkpow( f2, p.c[1][1])% mod;//f3
p.clear();
p.n =3, p.m =1;
p.c[1][1]=1;
p = v * p;
result = result *qkpow( f3, p.c[1][1])% mod;printf("%lld", result );return0;}
#include<cstdio>#include<cstring>#define mod 1000000007#define ll long longstruct Matrix {
ll c[101][101];void clear (){memset( c,0,sizeof( c ));}
Matrix operator*(const Matrix &p )const{
Matrix ans;
ans.clear();for(int i =0;i <=100;i ++)for(int k =0;k <=100;k ++)for(int j =0;j <=100;j ++)
ans.c[i][j]=( ans.c[i][j]+ c[i][k]* p.c[k][j]% mod )% mod;return ans;}}v, p;
Matrix qkpow( Matrix x, ll y ){
Matrix ans;
ans.clear();for(int i =0;i <=100;i ++)
ans.c[i][i]=1;while( y ){if( y &1) ans = ans * x;
x = x * x, y >>=1;}return ans;}
ll qkpow( ll x, ll y ){
ll ans =1;while( y ){if( y &1) ans = ans * x % mod;
x = x * x % mod, y >>=1;}return ans;}
ll n, k, cnt;int a[105];intmain(){scanf("%lld %lld",&n,&k );for(int i =1;i <= n;i ++)scanf("%d",&a[i]), cnt +=( a[i]==0);int tot =0;for(int i =1;i <= cnt;i ++)
tot +=( a[i]==0);
p.clear(), v.clear();
p.c[0][tot]=1;for( ll i =0;i <= cnt;i ++){if( i ) v.c[i -1][i]=( cnt - i +1)*( cnt - i +1)% mod;
v.c[i][i]=( i *( cnt - i )% mod +( cnt - i )*( n - cnt - cnt + i )% mod )% mod;
v.c[i][i]=( v.c[i][i]+ cnt *( cnt -1)/2% mod )% mod;
v.c[i][i]=( v.c[i][i]+( n - cnt )*( n - cnt -1)/2% mod )% mod;if( i < cnt ) v.c[i +1][i]=( i +1)*( n - cnt - cnt + i +1)% mod;}
v =qkpow( v, k );
p = p * v;
ll ans = p.c[0][cnt], temp =0;for(int i =0;i <= cnt;i ++)
temp =( temp + p.c[0][i])% mod;printf("%lld", ans *qkpow( temp, mod -2)% mod );return0;}