#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
const int N = 55, mod = 1e9 + 7;
int c[N][N], sum[N][2], dp[N][N][N][N], pw[N], n, a[N];
int main() {
  int p;
  read(n), read(p);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j)
      c[i][j] = j ? (c[i - 1][j - 1] + c[i - 1][j]) % mod : 1;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= i; ++j) (sum[i][j & 1] += c[i][j]) %= mod;
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) pw[i] = pw[i - 1] * 2 % mod;
  dp[0][0][0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int w = 0; w <= i; ++w)
      for (int ow = 0; ow <= w; ++ow)
        for (int ob = 0; w + ob <= i; ++ob)
          if (dp[i][w][ow][ob]) {
            if (a[i + 1] == 0 || a[i + 1] == -1) {
              (dp[i + 1][w + 1][ow + 1][ob] += dp[i][w][ow][ob] *
                                               (long long)pw[i - ob] % mod *
                                               sum[ob][0] % mod) %= mod;
              (dp[i + 1][w + 1][ow][ob] += dp[i][w][ow][ob] *
                                           (long long)pw[i - ob] % mod *
                                           sum[ob][1] % mod) %= mod;
            }
            if (a[i + 1] == 1 || a[i + 1] == -1) {
              (dp[i + 1][w][ow][ob + 1] += dp[i][w][ow][ob] *
                                           (long long)pw[i - ow] % mod *
                                           sum[ow][0] % mod) %= mod;
              (dp[i + 1][w][ow][ob] += dp[i][w][ow][ob] *
                                       (long long)pw[i - ow] % mod *
                                       sum[ow][1] % mod) %= mod;
            }
          }
  int ans = 0;
  for (int w = 0; w <= n; ++w)
    for (int ow = 0; ow <= w; ++ow)
      for (int ob = (p ^ (ow & 1)) ? 1 : 0; ob + w <= n; ob += 2)
        (ans += dp[n][w][ow][ob]) %= mod;
  printf("%d", ans);
  return 0;
}
