#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, vector<int>>> ks(M, pair<int, vector<int>>());
  for (int i = 0; i < M; i++) {
    cin >> ks[i].first;
    for (int j = 0; j < ks[i].first; j++) {
      int t;
      cin >> t;
      ks[i].second.push_back(t - 1);
    }
  }
  vector<int> p(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int result = 0;
  for (int i = 0; i <= (1 << N); i++) {
    vector<int> sw(N + 1, 0);
    for (int j = 0; j <= N; j++) {
      if ((i & (1 << j)) != 0) {
        sw[j] = 1;
      }
    }
    bool judge = true;
    for (int j = 0; j < M; j++) {
      int counter = 0;
      for (int k = 0; k < ks[j].first; k++) {
        counter += sw[ks[j].second[k]];
      }
      if ((counter % 2) != p[j]) {
        judge = false;
        break;
      }
    }
    if (judge) {
      result++;
    }
  }
  cout << result;
  return 0;
}
