#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int MOD = 1000000000 + 7;
int dp[N][N][N][N];
int c[N];
long long ceven[N];
long long codd[N];
long long fact[N];
long long inv_fact[N];
long long pow2[N];
long long power(long long s, long long p) {
  long long base = s;
  long long val = 1;
  long long tmp = p;
  while (tmp > 0) {
    if (tmp & 1) val = (val * base) % MOD;
    base = (base * base) % MOD;
    tmp >>= 1;
  }
  return val;
}
void init() {
  fact[0] = 1;
  pow2[0] = 1;
  for (int i = 1; i < N; i += 1) {
    fact[i] = (i * fact[i - 1]) % MOD;
    pow2[i] = (2 * pow2[i - 1]) % MOD;
  }
  inv_fact[N - 1] = power(fact[N - 1], MOD - 2);
  for (int i = N - 2; i >= 0; i--)
    inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % MOD;
  for (int i = 0; i < N; i += 1) {
    for (int j = 0; j <= i; j += 2) {
      ceven[i] += (((fact[i] * inv_fact[j]) % MOD) * inv_fact[i - j]) % MOD;
      ceven[i] %= MOD;
    }
    for (int j = 1; j <= i; j += 2) {
      codd[i] += (((fact[i] * inv_fact[j]) % MOD) * inv_fact[i - j]) % MOD;
      codd[i] %= MOD;
    }
  }
}
int main() {
  int n, p;
  cin >> n >> p;
  for (int i = 0; i < n; i += 1) cin >> c[i];
  init();
  long long ans = 0;
  dp[0][0][0][0] = 1;
  for (int i = 1; i <= n; i += 1) {
    for (int w1 = 0; w1 <= i; w1 += 1) {
      for (int w2 = 0; w2 + w1 <= i; w2 += 1) {
        for (int b1 = 0; b1 + w2 + w1 <= i; b1 += 1) {
          int b2 = i - w1 - w2 - b1;
          if (c[i - 1] == 0 || c[i - 1] == -1) {
            long long tpe = w1 == 0 ? 1 : pow2[w1 - 1];
            long long tpo = w1 == 0 ? 0 : pow2[w1 - 1];
            if (b1 > 0) {
              dp[i][w1][w2][b1] += (dp[i - 1][w1][w2][b1 - 1] * tpe % MOD) *
                                   pow2[w2 + b1 - 1 + b2] % MOD;
              dp[i][w1][w2][b1] %= MOD;
            }
            if (b2 > 0) {
              dp[i][w1][w2][b1] += (dp[i - 1][w1][w2][b1] * tpo % MOD) *
                                   pow2[w2 + b1 - 1 + b2] % MOD;
              dp[i][w1][w2][b1] %= MOD;
            }
          }
          if (c[i - 1] == 1 || c[i - 1] == -1) {
            long long tpe = b1 == 0 ? 1 : pow2[b1 - 1];
            long long tpo = b1 == 0 ? 0 : pow2[b1 - 1];
            if (w1 > 0) {
              dp[i][w1][w2][b1] += (dp[i - 1][w1 - 1][w2][b1] * tpe % MOD) *
                                   pow2[w1 - 1 + w2 + b2] % MOD;
              dp[i][w1][w2][b1] %= MOD;
            }
            if (w2 > 0) {
              dp[i][w1][w2][b1] += (dp[i - 1][w1][w2 - 1][b1] * tpo % MOD) *
                                   pow2[w1 + w2 - 1 + b2] % MOD;
              dp[i][w1][w2][b1] %= MOD;
            }
          }
          if (i == n && ((w1 + b1) & 1) == p) {
            ans += dp[i][w1][w2][b1];
            ans %= MOD;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
