#include <bits/stdc++.h>
using namespace std;
template <class C>
void min_self(C &a, C b) {
  a = min(a, b);
}
template <class C>
void max_self(C &a, C b) {
  a = max(a, b);
}
void mod(long long &n, long long m = 1000000007) { n %= m, n += m, n %= m; }
const int MAXN = 1e5 + 5;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int k[m + 3], p[m + 3];
  int s[m + 3][n + 3];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  int total = (1 << n);
  for (int i = 0; i < total; i++) {
    int aa = 0;
    for (int bulb = 0; bulb < m; bulb++) {
      int cc = 0;
      for (int kk = 0; kk < k[bulb]; kk++) {
        if ((1 << s[bulb][kk]) & i) {
          cc++;
        }
      }
      if (cc % 2 == p[bulb]) {
        aa++;
      }
    }
    if (aa == m) {
      ans++;
    }
  }
  cout << ans, cout << "\n";
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
