#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000;
const long long mod = 1000000007;
long long k[123], s[123][123], p[123];
signed main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  for (long long h = 0; h < m; h++) {
    cin >> k[h];
    for (long long i = 0; i < k[h]; i++) {
      cin >> s[h][i];
    }
  }
  for (long long h = 0; h < m; h++) {
    cin >> p[h];
  }
  for (long long i = 0; i <= (1 << n); i++) {
    vector<long long> sep = {};
    long long dame = 0;
    for (long long j = 0; j <= n - 1; j++) {
      if ((i & (1 << j)) > 0) {
        sep.push_back(j + 1);
      }
    }
    if (sep.size() == 0) {
      continue;
    }
    for (long long h = 0; h < m; h++) {
      long long cnt = 0;
      for (long long x = 0; x < k[h]; x++) {
        for (long long y = 0; y < sep.size(); y++) {
          if (s[h][x] == sep[y]) {
            cnt++;
          }
        }
      }
      if (cnt % 2 != p[h]) {
        dame = 1;
      }
    }
    if (dame == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
