#include <bits/stdc++.h>
const int mod = 1000000007;
int dp[60][60][60][60][2];
int p2[60];
void add(int &v, int x) {
  v += x;
  if (v >= mod) v -= mod;
}
inline int pp(int x, int d) {
  if (x == 0) return d == 0;
  return p2[x - 1];
}
int main() {
  int n, p;
  scanf("%d%d", &n, &p);
  dp[0][0][0][0][0] = 1;
  p2[0] = 1;
  for (int i = 0; i < n; i++) {
    p2[i + 1] = p2[i];
    add(p2[i + 1], p2[i]);
  }
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j <= i; j++) {
      int b = i - j;
      for (int k = 0; k <= j; k++) {
        int k0 = j - k;
        for (int l = 0; l <= b; l++) {
          int l0 = b - l;
          for (int m = 0; m < 2; m++) {
            for (int a = 0; a < 2; a++) {
              if (x <= 0) {
                add(dp[i + 1][j + 1][k + a][l][m ^ a],
                    (long long)dp[i][j][k][l][m] * pp(l, a ^ 1) % mod *
                        p2[j + l0] % mod);
              }
              if (x & 1) {
                add(dp[i + 1][j][k][l + a][m ^ a],
                    (long long)dp[i][j][k][l][m] * pp(k, a ^ 1) % mod *
                        p2[b + k0] % mod);
              }
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        add(ans, dp[n][i][j][k][p]);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
