#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline std::string to_bin_str(T n, std::size_t digit_num) {
  std::string str;
  while (n > 0) {
    str.push_back('0' + (n & 1));
    n >>= 1;
  }
  str.resize(digit_num, '0');
  std::reverse(str.begin(), str.end());
  return str;
}
int main() {
  int N, M;
  cin >> N >> M;
  int k[M], s[M][N], p[M];
  for (int i = 0; i < (int)(M); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) cin >> s[i][j];
  }
  for (int i = 0; i < (int)(M); i++) cin >> p[i];
  int ans = 0;
  string b[int(pow(2, N))];
  for (int i = 0; i < (int)(int(pow(2, N))); i++) b[i] = to_bin_str(i, N);
  for (int i = 0; i < (int)(int(pow(2, N))); i++) {
    for (int j = 0; j < (int)(M); j++) {
      int cnt = 0;
      for (int l = 0; l < (int)(k[j]); l++) {
        if (b[i][s[j][l] - 1] == '1') cnt++;
      }
      if (cnt % 2 != p[j]) {
        j = 0;
        cnt = 0;
        i++;
      }
      if (j == M - 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
