#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
const int SIZE = 50;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec[SIZE];
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      vec[i].push_back(s);
    }
  }
  vector<int> P;
  for (int i = 0; i < M; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  int ans = 0;
  for (int state = 0; state < (1 << N); state++) {
    int di[SIZE] = {};
    for (int i = 0; i < N; i++) {
      if (state & (1 << i)) {
        for (int j : vec[i]) di[j]++;
      }
    }
    bool flag = 1;
    for (int i = 0; i < M; i++) {
      if (di[i] % 2 != P[i]) flag = 0;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
