#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[10][10];
  int k[10];
  for (int i = 0; i < M; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      int t;
      cin >> t;
      A[i][j] = t - 1;
    }
  }
  int p[10];
  for (int i = 0; i < M; ++i) {
    cin >> p[i];
  }
  int max = pow(2, N);
  int s[10];
  int ans = 0;
  for (int i = 0; i < max; ++i) {
    bool flag = true;
    int tempi = i;
    for (int j = 0; j < N; ++j) {
      s[j] = tempi % 2;
      tempi /= 2;
    }
    int temp = 0;
    for (int j = 0; j < M; ++j) {
      for (int l = 0; l < k[j]; ++l) {
        temp += s[A[j][l]];
      }
      if ((temp % 2) != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
