#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  bool table[11][11];
  int K[10];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    K[i] = k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      table[i][a - 1] = true;
    }
  }
  int List[11];
  for (int i = 0; i < M; i++) {
    cin >> List[i];
  }
  int n = pow(2, N);
  for (int i = 0; i < n; i++) {
    bool frag = 1;
    vector<int> X(10, 0);
    int t = i;
    for (int j = 0; j < i; j++) {
      X[j] = t % 2;
      t = (t - t % 2) / 2;
      if (t == 0) {
        break;
      }
    }
    bool judge = true;
    for (int k = 0; k < M; k++) {
      int cnt = 0;
      for (int o = 0; o < K[k]; o++) {
        if (table[k][o]) {
          if (X[o] == 1) {
            cnt++;
          }
        }
      }
      if (cnt % 2 != List[k]) {
        judge = 0;
      }
    }
    if (judge) {
      ans++;
    }
  }
  cout << ans << endl;
}
