#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(N);
  for (int i = 0; i < (int)(M); ++i) {
    int k;
    cin >> k;
    for (int i = 0; i < (int)(k); ++i) {
      int s;
      cin >> s;
      S[s - 1].push_back(i);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (int)(M); ++i) cin >> p[i];
  int cnt = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    vector<int> X;
    for (int i = 0; i < (int)(N); ++i) {
      if (bit & (1 << i)) X.push_back(i);
    }
    vector<int> P(M, 0);
    for (int x : X) {
      for (int y : S[x]) ++P[y];
    }
    for (int i = 0; i < (int)(M); ++i) P[i] %= 2;
    bool judge = true;
    for (int i = 0; i < (int)(M); ++i) {
      if (p[i] != P[i]) judge = false;
    }
    if (judge) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}
