#include <bits/stdc++.h>
using namespace std;
vector<int> int2vec(int num, int n) {
  vector<int> v;
  for (int i = 0; i < n; i++) {
    v.push_back(num % 2);
    num = num / 2;
  }
  return v;
}
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int>> K(m);
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int s;
      scanf("%d", &s);
      K[i].push_back(s);
    }
  }
  vector<int> P;
  for (int i = 0; i < m; i++) {
    int p;
    scanf("%d", &p);
    P.push_back(p);
  }
  int pow_2_n = 1;
  for (int i = 0; i < n; i++) {
    pow_2_n *= 2;
  }
  int cnt = 0;
  for (int i = 0; i < pow_2_n; i++) {
    vector<int> v = int2vec(i, n);
    for (int j = 0; j < m; j++) {
      int sum = 0;
      for (int l = 0; l < K[j].size(); l++) {
        sum += v[K[j][l]];
      }
      if (sum % 2 != P[j]) {
        goto NEXT;
      }
    }
    cnt++;
  NEXT:
    cnt = cnt;
  }
  printf("%d\n", cnt);
}
