#include <bits/stdc++.h>
using namespace std;
int n, k, dp[(1 << 12)][2031][3], a[(int)(2e5 + 10)];
int f(int mask, int x, int y) {
  if ((mask >> k) & 1) {
    mask = 0;
    y = 1;
  }
  if (x == n + 1) {
    int ff = 0;
    for (int i = k; i <= 11; i++)
      if ((mask >> i) & 1) ff = 1;
    return (ff or y);
  }
  int &r = dp[mask][x][y];
  if (r != -1) return r;
  for (int i = k; i <= 11; i++)
    if ((mask >> i) & 1) y = 1;
  r = 0;
  if (a[x] == 0) {
    if (!((mask >> 1) & 1))
      r = f(mask + 4, x + 1, y);
    else
      r = f(4, x + 1, y);
    r = (r + f(mask + 2, x + 1, y)) % 1000000007;
  } else if (a[x] == 4) {
    if (!((mask >> 1) & 1))
      r = f(mask + 4, x + 1, y);
    else
      r = f(4, x + 1, y);
  } else
    r = f(mask + 2, x + 1, y);
  return r %= 1000000007;
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  cout << f(0, 1, 0) << '\n';
}
