#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  vector<int> k, p;
  vector<uint16_t> s;
  cin >> N >> M;
  int k_tmp, s_tmp, p_tmp;
  for (int i = 0; i < (int)(M); i++) {
    cin >> k_tmp;
    k.push_back(k_tmp);
    s.push_back(0);
    for (int j = 0; j < (int)(k_tmp); j++) {
      cin >> s_tmp;
      s[i] |= 1 << (s_tmp - 1);
    }
  }
  for (int i = 0; i < (int)(M); i++) {
    cin >> p_tmp;
    p.push_back(p_tmp);
  }
  int Num = 0;
  for (int i = 0; i < (int)(pow(2, N)); i++) {
    for (int j = 0; j < (int)(M); j++) {
      int tmp = s[j] & i;
      int count = 0;
      for (int bit = 0; bit < (int)(sizeof(uint16_t)); bit++) {
        if (tmp & 1) count++;
        tmp >>= 1;
      }
      if (count % 2 != p[j]) break;
      if (j == M - 1) Num++;
    }
  }
  cout << Num << endl;
}
