#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int n, k;
int dp[2005][4096];
int main() {
  dp[0][0] = 1;
  scanf("%d%d", &n, &k);
  for (int i = (1); i <= (n); ++i) {
    int x;
    scanf("%d", &x);
    for (int j = (0); j <= ((1 << k)); ++j) {
      if (x == 2 || x == 0)
        dp[i][min(j + 2, 1 << k)] =
            (dp[i][min(j + 2, 1 << k)] + dp[i - 1][j]) % p;
      if (x == 4 || x == 0) {
        if (j % 4 == 2)
          dp[i][4] = (dp[i - 1][j] + dp[i][4]) % p;
        else
          dp[i][min(j + 4, 1 << k)] =
              (dp[i][min(j + 4, 1 << k)] + dp[i - 1][j]) % p;
      }
    }
  }
  printf("%d\n", dp[n][1 << k]);
  return 0;
}
