#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * inf;
const int N = 57;
const int M = 1000000 + 3;
const int multipleTest = 0;
const double pi = acos(-1);
void add(long long& a, long long b) {
  a += b % inf;
  if (a >= inf) a -= inf;
  if (a >= inf) a %= inf;
}
long long C[N][N];
long long f[N][N][2];
long long dp[2][N][N][N];
long long lt[N];
int n, k;
void solve() {
  lt[0] = 1;
  for (int i = (1), _b = (N); i < _b; ++i) lt[i] = lt[i - 1] * 2 % inf;
  C[0][0] = 1;
  for (int i = (1), _b = (N); i < _b; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = (1), _b = (i); j < _b; ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % inf;
  }
  for (int u = (0), _b = (N); u < _b; ++u)
    for (int v = (0), _b = (N); v < _b; ++v) {
      for (int p = (0), _b = (u + 1); p < _b; ++p)
        for (int q = (0), _b = (v + 1); q < _b; ++q) {
          add(f[u][v][((q + 1) & 1)], C[u][p] * C[v][q]);
        }
    }
  cin >> n >> k;
  int cur = 0;
  dp[cur][0][0][0] = 1;
  for (int i = (0), _b = (n); i < _b; ++i) {
    int u;
    scanf("%d", &u);
    vector<int> p;
    if (u != -1)
      p.push_back(u);
    else {
      p.push_back(0);
      p.push_back(1);
    }
    int pre = cur;
    cur ^= 1;
    for (int u00 = (0), _b = (i + 2); u00 < _b; ++u00)
      for (int u01 = (0), _b = (i + 2 - u01); u01 < _b; ++u01)
        for (int v10 = (0), _b = (i + 2 - u00 - u01); v10 < _b; ++v10)
          dp[cur][u00][u01][v10] = 0;
    for (int u : p) {
      for (int u00 = (0), _b = (i + 1); u00 < _b; ++u00)
        for (int u01 = (0), _b = (i + 1 - u00); u01 < _b; ++u01)
          for (int v10 = (0), _b = (i + 1 - u01 - u00); v10 < _b; ++v10) {
            int v11 = i - u00 - u01 - v10;
            long long val = dp[pre][u00][u01][v10];
            if (val == 0) continue;
            if (u == 0) {
              val = val * lt[u00 + u01] % inf;
              add(dp[cur][u00 + 1][u01][v10], val * f[v10][v11][0]);
              add(dp[cur][u00][u01 + 1][v10], val * f[v10][v11][1]);
            } else {
              val = val * lt[v10 + v11] % inf;
              add(dp[cur][u00][u01][v10 + 1], val * f[u00][u01][0]);
              add(dp[cur][u00][u01][v10], val * f[u00][u01][1]);
            }
          }
    }
  }
  long long res = 0;
  for (int u = (0), _b = (N); u < _b; ++u)
    for (int v = (0), _b = (N); v < _b; ++v)
      for (int p = (0), _b = (N); p < _b; ++p) {
        int t = n - u - v - p;
        if (t >= 0 && (v + t) % 2 == k) add(res, dp[cur][u][v][p]);
      }
  cout << res;
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}
