#include<bits/stdc++.h> #define MAX_N 1000 #define STANUM (1<<15) #define P 1000000007 usingnamespace std; template <classT> inlinevoidread(T &x){ x = 0; int c = getchar(), f = 1; for (; !isdigit(c); c = getchar()) if (c == 45) f = -1; for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0'); } int n, m, s[20]; char str[20]; int trans[STANUM][3], ans[20]; int f[2][STANUM][3], g[20], h[20]; int nxt[3][3] = {{1, 0, 0}, {1, 2, 0}, {1, 0, 3}}; intnum(char ch){ if (ch == 'N') return0; if (ch == 'O') return1; return2; } voidcompress(int *arr, int &x){ x = 0; for (int i = 1; i <= m; i++) x |= (arr[i]-arr[i-1])<<(i-1); } voidexpress(int *arr, int x){ arr[0] = 0; for (int i = 1; i <= m; i++) arr[i] = arr[i-1]+(x>>(i-1)&1); } voidinit(){ f[0][0][0] = 1; for (int i = 1; i <= m; i++) s[i] = num(str[i]); for (int c = 0; c < 3; c++) { for (int sta = 0; sta < (1<<m); sta++) { express(g, sta), memset(h, 0, sizeof h); for (int i = 1; i <= m; i++) h[i] = max(g[i], h[i-1]), h[i] = max(h[i], g[i-1]+(c == s[i])); compress(h, trans[sta][c]); } } } intmain(){ read(n), read(m), scanf("%s", str+1), init(); for (int i = 0, c = 0; i < n; i++, c ^= 1) for (int sta = 0; sta < (1<<m); sta++) for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) if (nxt[j][k]^3) (f[c^1][trans[sta][k]][nxt[j][k]] += f[c][sta][j]) %= P; f[c][sta][j] = 0; } for (int sta = 0; sta < (1<<m); sta++) for (int i = 0; i < 3; i++) (ans[__builtin_popcount(sta)] += f[n&1][sta][i]) %= P; for (int i = 0; i <= m; i++) printf("%d\n", ans[i]); return0; }