#include <bits/stdc++.h>
using namespace std;
long long dp[51][51][51][51];
int n, p, c[51];
long long even[51], odd[51], pascal[51][51], p2[51];
void init() {
  p2[0] = 1;
  for (int i = 1; (i) <= int(51 - 1); (i)++)
    p2[i] = (2 * p2[i - 1]) % 1000000007;
  for (int n = 0; (n) < int(51); (n)++)
    for (int k = 0; (k) < int(51); (k)++) {
      if (k > n)
        pascal[n][k] = 0;
      else if (k == 0 || k == n)
        pascal[n][k] = 1;
      else
        pascal[n][k] = (pascal[n - 1][k] + pascal[n - 1][k - 1]) % 1000000007;
    }
  for (int n = 0; (n) < int(51); (n)++) {
    even[n] = 0;
    odd[n] = 0;
    for (int k = 0; (k) < int(n + 1); (k)++) {
      if (k % 2 == 0)
        even[n] = (even[n] + pascal[n][k]) % 1000000007;
      else
        odd[n] = (odd[n] + pascal[n][k]) % 1000000007;
    }
  }
}
int main() {
  init();
  scanf("%d %d", &n, &p);
  for (int i = 1; (i) <= int(n); (i)++) scanf("%d", &c[i]);
  long long ans = 0;
  for (int i = 0; i <= n; i++)
    for (int ew = 0; ew <= i; ew++)
      for (int ow = 0; ew + ow <= i; ow++)
        for (int eb = 0; ew + ow + eb <= i; eb++) {
          int ob = i - ew - ow - eb;
          if (i == 0) {
            dp[i][ew][ow][eb] = 1;
            continue;
          }
          dp[i][ew][ow][eb] = 0;
          if (c[i] == 1 || c[i] == -1) {
            if (ow > 0) {
              dp[i][ew][ow][eb] += (dp[i - 1][ew][ow - 1][eb] *
                                    p2[ow + ew - 1 + eb] % 1000000007) *
                                   even[ob] % 1000000007;
              dp[i][ew][ow][eb] %= 1000000007;
            }
            if (ew > 0) {
              dp[i][ew][ow][eb] += (dp[i - 1][ew - 1][ow][eb] *
                                    p2[ow + ew - 1 + eb] % 1000000007) *
                                   odd[ob] % 1000000007;
              dp[i][ew][ow][eb] %= 1000000007;
            }
          }
          if (c[i] == 0 || c[i] == -1) {
            if (ob > 0) {
              dp[i][ew][ow][eb] +=
                  (dp[i - 1][ew][ow][eb] * p2[ob + eb - 1 + ew] % 1000000007) *
                  even[ow] % 1000000007;
              dp[i][ew][ow][eb] %= 1000000007;
            }
            if (eb > 0) {
              dp[i][ew][ow][eb] += (dp[i - 1][ew][ow][eb - 1] *
                                    p2[ob + eb - 1 + ew] % 1000000007) *
                                   odd[ow] % 1000000007;
              dp[i][ew][ow][eb] %= 1000000007;
            }
          }
          if (i == n && (ob + ow) % 2 == p)
            ans = (ans + dp[i][ew][ow][eb]) % 1000000007;
        }
  printf("%lld\n", ans);
  return 0;
}
