#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> a[m];
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long s;
      cin >> s;
      a[i].push_back(s - 1);
    }
  }
  long long p[m];
  for (long long i = 0; i < m; i++) {
    cin >> p[i];
    p[i] %= 2;
  }
  long long ans = 0;
  for (long long i = 0; i < (1 << n); i++) {
    long long Ans[n];
    memset(Ans, 0, sizeof(Ans));
    for (long long j = 0; j < n; j++) {
      if (i & (1 << j) > 0) {
        Ans[j]++;
      }
    }
    bool flg = true;
    for (long long i = 0; i < m; i++) {
      long long k = a[i].size();
      long long cnt = 0;
      for (long long j = 0; j < k; j++) {
        cnt += Ans[a[i][j]];
      }
      if ((cnt % 2) != p[i]) flg = false;
    }
    if (flg) ans++;
  }
  cout << ans / 2;
  ;
}
