#include <bits/stdc++.h>
using namespace std;
long long dp[55][55][55][55];
int n, typ;
int c[55];
long long mul[55];
int main() {
  scanf("%d%d", &n, &typ);
  mul[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    mul[i] = (mul[i - 1] << 1) % 1000000007;
  }
  long long ret = 0;
  if (c[1] == 0 || c[1] == -1) {
    dp[1][0][1][0] = 1;
    if (typ == 1 && n == 1) {
      ret++;
    }
  }
  if (c[1] == 1 || c[1] == -1) {
    dp[1][1][0][0] = 1;
    if (typ == 1 && n == 1) {
      ret++;
    }
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k + j <= i; k++) {
        for (int p = 0; j + k + p <= i; p++) {
          int t = i - j - k - p;
          if (c[i] == 1 || c[i] == -1) {
            long long s = 0;
            if (j + p) {
              if (j) {
                if (!k) {
                  s += dp[i - 1][j - 1][k][p];
                } else {
                  s += mul[k - 1] * dp[i - 1][j - 1][k][p] % 1000000007;
                }
                s %= 1000000007;
              }
              if (p) {
                if (k) {
                  s += mul[k - 1] * dp[i - 1][j][k][p - 1] % 1000000007;
                }
                s %= 1000000007;
              }
            }
            s *= mul[j + p + t - 1];
            s %= 1000000007;
            dp[i][j][k][p] += s;
            dp[i][j][k][p] %= 1000000007;
          }
          if (c[i] == 0 || c[i] == -1) {
            long long s = 0;
            if (k + t) {
              if (k) {
                if (!j) {
                  s += dp[i - 1][j][k - 1][p];
                } else {
                  s += mul[j - 1] * dp[i - 1][j][k - 1][p] % 1000000007;
                }
                s %= 1000000007;
              }
              if (t) {
                if (j) {
                  s += mul[j - 1] * dp[i - 1][j][k][p] % 1000000007;
                }
                s %= 1000000007;
              }
            }
            s *= mul[k + p + t - 1];
            s %= 1000000007;
            dp[i][j][k][p] += s;
            dp[i][j][k][p] %= 1000000007;
          }
          if (i == n) {
            if ((j + k) % 2 == typ) {
              ret += dp[i][j][k][p];
              ret %= 1000000007;
            }
          }
        }
      }
    }
  }
  printf("%lld\n", ret);
  return 0;
}
