#include <bits/stdc++.h>
using lli = long long int;
int inf = 1000000007;
using namespace std;
int N, M;
int main() {
  cin >> N >> M;
  vector<vector<int>> data(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      data[i].push_back(s);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    int pi;
    cin >> pi;
    p.push_back(pi);
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> c(M);
    for (int j = 0; j < M; j++) c[j] = 0;
    for (int k = 0; k < N; k++) {
      if ((1 & bit >> k)) {
        for (int j = 0; j < M; j++) {
          if (count(data[j].begin(), data[j].end(), k + 1) > 0) {
            c[j] += 1;
          }
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (c[j] % 2 == p[j]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
