#include <bits/stdc++.h>
using namespace std;
const long long mod = 2019;
const long long INF = 1e+14;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
void Yes() {
  cout << "Yes" << endl;
  exit(0);
}
void No() {
  cout << "No" << endl;
  exit(0);
}
int main() {
  int N, M;
  cin >> N >> M;
  int k[M];
  vector<int> s[M];
  int p[M];
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    k[i] = a;
    for (int j = 0; j < k[i]; j++) {
      int b;
      cin >> b;
      s[i].push_back(b);
    }
  }
  for (int i = 0; i < M; i++) {
    int c;
    cin >> c;
    p[i] = c;
  }
  int D[M + 1];
  for (int i = 0; i < M + 1; i++) {
    D[i] = 0;
  }
  int count = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        D[i + 1] = 1;
      }
    }
    bool ok = true;
    for (int i = 0; i < M; i++) {
      int judge = 0;
      for (int j = 0; j < k[i]; j++) {
        judge += D[s[i][j]];
      }
      if (judge % 2 != p[i]) ok = false;
    }
    if (ok) count++;
    for (int i = 1; i <= M; i++) {
      D[i] = 0;
    }
  }
  cout << count << endl;
}
