#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e3 + 9;
const long long oo = 1e15;
const long long mod = 1e9 + 7;
int n, k;
long long a[N], dp[N][4100][2];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j < (1 << 12); ++j) dp[i][j][0] = dp[i][j][1] = 0ll;
  dp[0][0][0] = 1ll;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < (1 << 12); ++j) {
      if (dp[i][j][0] > 0ll) {
        if (a[i + 1] == 2 || !a[i + 1]) {
          int pos = 10, mask = j;
          while (pos > 0 && (j & (1 << (11 - pos))) > 0)
            mask ^= (1 << (11 - pos)), pos--;
          mask |= (1 << (11 - pos));
          if (11 - pos >= k)
            dp[i + 1][mask][1] = (dp[i + 1][mask][1] + dp[i][j][0]) % mod;
          else
            dp[i + 1][mask][0] = (dp[i + 1][mask][0] + dp[i][j][0]) % mod;
        }
        if (a[i + 1] == 4 || !a[i + 1]) {
          int pos = 9, mask = j;
          if ((mask & (1 << 1)) > 0)
            mask = (1 << 2);
          else {
            while (pos > 0 && (j & (1 << (11 - pos))) > 0)
              mask ^= (1 << (11 - pos)), pos--;
            mask |= (1 << (11 - pos));
          }
          if (11 - pos >= k)
            dp[i + 1][mask][1] = (dp[i + 1][mask][1] + dp[i][j][0]) % mod;
          else
            dp[i + 1][mask][0] = (dp[i + 1][mask][0] + dp[i][j][0]) % mod;
        }
      }
      if (dp[i][j][1] > 0ll) {
        if (a[i + 1] == 2 || !a[i + 1]) {
          int pos = 10, mask = j;
          while (pos > 0 && (j & (1 << (11 - pos))))
            mask ^= (1 << (11 - pos)), pos--;
          mask |= (1 << (11 - pos));
          dp[i + 1][mask][1] = (dp[i + 1][mask][1] + dp[i][j][1]) % mod;
        }
        if (a[i + 1] == 4 || !a[i + 1]) {
          int pos = 9, mask = j;
          if (mask & (1 << 1))
            mask = (1 << 2);
          else {
            while (pos > 0 && (j & (1 << (11 - pos))) > 0)
              mask ^= (1 << (11 - pos)), pos--;
            mask |= (1 << (11 - pos));
          }
          dp[i + 1][mask][1] = (dp[i + 1][mask][1] + dp[i][j][1]) % mod;
        }
      }
    }
  long long res = 0ll;
  for (int i = 0; i < (1 << 12); ++i) res = (res + dp[n][i][1]) % mod;
  printf("%lld", res);
}
