1 #include<cstdio>
2 #include<cstring>
3 #include<algorithm>
4 #define mo 1000000007
5 using namespace std;
6 int n,k;
7 char s[1000];
8 struct mat{
9 int m[130][130];
10 mat(){
11 for (int i=0;i<(1<<n);i++)
12 for (int j=0;j<(1<<n);j++)
13 m[i][j]=0;
14 }
15 } a[2];
16 mat mul(mat a,mat b){
17 mat re;
18 for (int i=0;i<(1<<n);i++)
19 for (int j=0;j<(1<<n);j++)
20 for (int k=0;k<(1<<n);k++){
21 re.m[i][j]+=1ll*a.m[i][k]*b.m[k][j]%mo;
22 if (re.m[i][j]>=mo) re.m[i][j]-=mo;
23 }
24 return re;
25 }
26 int main(){
27 scanf("%d%d%s",&n,&k,&s);int len=strlen(s);
28
29 for (int zt=0;zt<(1<<n);zt++){
30 for (int zy=0;zy<(1<<n);zy++){
31 int td=0;
32 for (int i=1;i<=n;i++) if (zy&(1<<(i-1))) td++;
33 if (td&1) continue;
34
35 if (zt&1){
36 int ha=0;
37 for (int i=n;i;i--){
38 if (zy&(1<<(i-1))) ha=1;
39 if (zt&(1<<(i-1))) break;
40 }
41 if (ha) continue;
42 }
43
44 td=0;
45 for (int i=1;i<n;i++) if ((zy&(1<<(i-1)))&&!(zy&(1<<i))){
46 if (!(zt&(1<<i))) td=1;
47 }
48 if (td) continue;
49
50 int go=zt;
51 for (int i=1;i<n;i++) if (!(zy&(1<<(i-1)))&&(zy&(1<<i)))
52 go|=(1<<i);
53 a[0].m[go][zt]++;
54 }
55 }
56
57 for (int zt=0;zt<(1<<n);zt++){
58 for (int zy=0;zy<(1<<n);zy++){
59 int td=0;
60 for (int i=1;i<=n;i++) if (zy&(1<<(i-1))) td++;
61 if (td&1) continue;
62
63 int ha=0;
64 for (int i=n;i;i--){
65 if (zy&(1<<(i-1))) ha=1;
66 if (zt&(1<<(i-1))) break;
67 }
68
69 td=0;
70 for (int i=1;i<n;i++) if ((zy&(1<<(i-1)))&&!(zy&(1<<i))){
71 if (!(zt&(1<<i))) td=1;
72 }
73 if (td) continue;
74
75 int go=zt;
76 for (int i=1;i<n;i++) if (!(zy&(1<<(i-1)))&&(zy&(1<<i)))
77 go|=(1<<i);
78 if (!ha&&(go&1)) go^=1;
79 a[1].m[go][zt]++;
80 }
81 }
82
83 mat td,ret,lj,init;
84 for (int i=0;i<(1<<n);i++) td.m[i][i]=ret.m[i][i]=1;
85 for (int i=0;i<len;i++) td=mul(a[s[i]-‘0‘],td);
86 for (lj=td;k;k/=2,lj=mul(lj,lj)) if (k&1)
87 ret=mul(ret,lj);
88 init.m[1][0]=1;
89 ret=mul(ret,init);
90 printf("%d\n",ret.m[(1<<n)-2][0]);
91 }