#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> K;
vector<pair<int, int> *> S;
vector<int> P;
int main(int argc, char **argv) {
  int k;
  pair<int, int> *s;
  int stemp;
  int p;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k;
    K.push_back(k);
    for (int j = 0; j < k; j++) {
      cin >> stemp;
      S.push_back(new pair<int, int>(j, stemp - 1));
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p;
    P.push_back(p);
  }
  int ans = 0;
  bool allon = true;
  bitset<10> *switch_on;
  for (int i = 0; i < pow(2, N); i++) {
    switch_on = new bitset<10>(i);
    allon = true;
    for (int j = 0; j < M; j++) {
      int on_num = 0;
      for (int k = 0; k < K[j]; k++) {
        if (switch_on->test((size_t)(S[k]->second))) {
          on_num++;
        }
      }
      if (on_num % 2 != P[j]) {
        allon = false;
        break;
      }
    }
    if (allon) {
      ans++;
    }
    free(switch_on);
  }
  cout << ans << endl;
  return 0;
}
