#include <bits/stdc++.h>
using namespace std;
int N, M;
int res = 0;
vector<vector<int>> S(0);
vector<int> P(0);
void calc(vector<int> v) {
  int countOn = 0;
  bool OK = true;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < S.at(i).size(); j++) {
      if (v.at(S.at(i).at(j) - 1) == 1) countOn++;
    }
    if (countOn % 2 != P.at(i)) OK = false;
  }
  if (OK) res++;
}
void dfs(int depth, vector<int> v) {
  if (depth == N) {
    calc(v);
    return;
  }
  for (int i = 0; i < 2; i++) {
    v.at(depth) = i;
    dfs(depth + 1, v);
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vector<int> s(k);
    for (int j = 0; j < k; j++) {
      cin >> s.at(j);
    }
    S.push_back(s);
  }
  vector<int> v(N);
  for (int i = 0; i < M; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  dfs(0, v);
  cout << res;
}
