#include <bits/stdc++.h>
using namespace std;
int k[11];
int p[11];
int s[11][11];
int total = 0;
vector<array<int, 11>> v;
array<int, 11> ar;
int dfs(int* S, int I, int n) {
  if (I >= n) {
    for (int i = 0; i <= 11; i++) {
      ar[i] = S[i];
    }
    v.push_back(ar);
    return 1;
  } else {
    S[I] = 0;
    dfs(S, I + 1, n);
    S[I] = 1;
    dfs(S, I + 1, n);
    return 1;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int tmp;
      cin >> tmp;
      s[i][tmp - 1] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int S[11];
  S[0] = 0;
  dfs(S, 1, n);
  S[0] = 1;
  dfs(S, 1, n);
  int ret = 0;
  for (int i = 0; i < (int)v.size(); i++) {
    total = 0;
    for (int j = 0; j < m; j++) {
      int on = 0;
      for (int k = 0; k < n; k++) {
        if (v[i][j] == 1 && s[j][k]) {
          on++;
        }
      }
      if (on % 2 == p[j] && on != 0) {
        total++;
      }
    }
    if (total == m) {
      ret++;
    }
  }
  cout << ret << endl;
}
