#include <bits/stdc++.h>
using namespace std;
int n, p, c[55], mo = 1000000007;
int dp[52][52][52][52];
int bi[52][52], p2[52];
int ans() {
  for (int s = 0; s < 52; s++) {
    bi[s][0] = bi[s][s] = 1;
    for (int i = 1; i < s; i++)
      bi[s][i] = (bi[s - 1][i - 1] + bi[s - 1][i]) % mo;
  }
  p2[0] = 1;
  for (int i = 1; i < 52; i++) {
    p2[i] = p2[i - 1] * 2 % mo;
  }
  dp[0][0][0][0] = 1;
  long long pre;
  int b1;
  for (int s = 0; s < n; s++) {
    for (int w0 = 0; w0 <= s; w0++)
      for (int w1 = 0; w1 + w0 <= s; w1++)
        for (int b0 = 0; b0 + w0 + w1 <= s; b0++)
          if (pre = dp[s][w0][w1][b0]) {
            b1 = s - w0 - w1 - b0;
            if (c[s] < 0 || c[s] == 1) {
              for (int x = 0; x <= b1; x++) {
                int &z = dp[s + 1][w0 + (x) % 2][w1 + (x + 1) % 2][b0];
                z = (z + pre * p2[s - b1] % mo * bi[b1][x]) % mo;
              }
            }
            if (c[s] < 0 || c[s] == 0) {
              for (int x = 0; x <= w1; x++) {
                int &z = dp[s + 1][w0][w1][b0 + x % 2];
                z = (z + pre * p2[s - w1] % mo * bi[w1][x]) % mo;
              }
            }
          }
  }
  int re = 0;
  for (int w0 = 0; w0 <= n; w0++)
    for (int w1 = 0; w1 + w0 <= n; w1++)
      for (int b0 = 0; b0 + w0 + w1 <= n; b0++) {
        b1 = n - w0 - w1 - b0;
        if ((w1 + b1) % 2 == p) re = (re + dp[n][w0][w1][b0]) % mo;
      }
  return re;
}
int main() {
  cin >> n >> p;
  for (int i = 0; i < n; i++) cin >> c[i];
  cout << ans() << endl;
}
