#include <bits/stdc++.h>
using namespace std;
const int N = 55, mod = 1000000007;
int dp[N][N][N][N], n, c[N], pw[N], jo;
void upd(int& x) {
  if (x >= mod) x -= mod;
}
int main() {
  scanf("%d%d", &n, &jo);
  pw[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    pw[i] = pw[i - 1] * 2 % mod;
  }
  dp[0][0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int b0 = 0; b0 < i; b0++) {
      for (int b1 = 0; b0 + b1 < i; b1++) {
        for (int c0 = 0; b0 + b1 + c0 < i; c0++) {
          int c1 = i - b0 - b1 - c0 - 1;
          if (c[i] == -1 || c[i] == 0) {
            if (c1) {
              dp[i][b0 + 1][b1][c0] +=
                  (long long)dp[i - 1][b0][b1][c0] * pw[i - 2] % mod;
              dp[i][b0][b1 + 1][c0] +=
                  (long long)dp[i - 1][b0][b1][c0] * pw[i - 2] % mod;
            } else {
              dp[i][b0][b1 + 1][c0] +=
                  (long long)dp[i - 1][b0][b1][c0] * pw[i - 1] % mod;
            }
            upd(dp[i][b0 + 1][b1][c0]), upd(dp[i][b0][b1 + 1][c0]);
          }
          if (c[i] == -1 || c[i] == 1) {
            if (b1) {
              dp[i][b0][b1][c0 + 1] +=
                  (long long)dp[i - 1][b0][b1][c0] * pw[i - 2] % mod;
              dp[i][b0][b1][c0] +=
                  (long long)dp[i - 1][b0][b1][c0] * pw[i - 2] % mod;
            } else {
              dp[i][b0][b1][c0] +=
                  (long long)dp[i - 1][b0][b1][c0] * pw[i - 1] % mod;
            }
            upd(dp[i][b0][b1][c0 + 1]), upd(dp[i][b0][b1][c0]);
          }
        }
      }
    }
  }
  int ans = 0;
  for (int b0 = 0; b0 <= n; b0++) {
    for (int b1 = 0; b0 + b1 <= n; b1++) {
      for (int c0 = 0; b0 + b1 + c0 <= n; c0++) {
        int c1 = n - b0 - b1 - c0;
        if ((b1 + c1 & 1) == jo) ans += dp[n][b0][b1][c0], upd(ans);
      }
    }
  }
  printf("%d\n", ans);
}
