#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int n, k;
long long f[2010][(1 << 11) + 1];
int a[2010];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  f[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= (1 << k); j++) {
      if (a[i] != 4) {
        if (j >= (1 << k))
          (f[i][j] += f[i - 1][j]) %= MOD;
        else
          (f[i][min(j + 2, 1 << k)] += f[i - 1][j]) %= MOD;
      }
      if (a[i] != 2) {
        if (j >= (1 << k))
          (f[i][j] += f[i - 1][j]) %= MOD;
        else
          (f[i][min((j & 3) ? 4 : j + 4, 1 << k)] += f[i - 1][j]) %= MOD;
      }
    }
  cout << f[n][1 << k] << endl;
  return 0;
}
