#include <bits/stdc++.h>
using namespace std;
int sw[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int swcountup() {
  if (sw[0] == 0) {
    sw[0] = 1;
  } else if (sw[1] == 0) {
    sw[1] = 1;
    sw[0] = 0;
  } else if (sw[2] == 0) {
    sw[2] = 1;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[3] == 0) {
    sw[3] = 1;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[4] == 0) {
    sw[4] = 1;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[5] == 0) {
    sw[5] = 1;
    sw[4] = 0;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[6] == 0) {
    sw[6] = 1;
    sw[5] = 0;
    sw[4] = 0;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[7] == 0) {
    sw[7] = 1;
    sw[6] = 0;
    sw[5] = 0;
    sw[4] = 0;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[8] == 0) {
    sw[8] = 1;
    sw[7] = 0;
    sw[6] = 0;
    sw[5] = 0;
    sw[4] = 0;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[9] == 0) {
    sw[9] = 1;
    sw[8] = 0;
    sw[7] = 0;
    sw[6] = 0;
    sw[5] = 0;
    sw[4] = 0;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  } else if (sw[10] == 0) {
    sw[10] = 1;
    sw[9] = 0;
    sw[8] = 0;
    sw[7] = 0;
    sw[6] = 0;
    sw[5] = 0;
    sw[4] = 0;
    sw[3] = 0;
    sw[2] = 0;
    sw[1] = 0;
    sw[0] = 0;
  }
  return 0;
}
int ans = 0;
int main() {
  int n, m;
  cin >> n >> m;
  int k[10];
  int s[10][10];
  int p[10];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  bool b = false;
  while (sw[n] == 0) {
    b = true;
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < k[j]; j++) {
        if (sw[s[i][j] - 1] == 1) count++;
      }
      if (count % 2 != p[i]) {
        b = false;
      }
    }
    if (b == true) {
      ans++;
    }
    swcountup();
  }
  cout << ans << endl;
}
