#include <bits/stdc++.h>
using namespace std;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vector<int> s(k);
    for (int j = 0; j < k; j++) {
      cin >> s[j];
    }
    S.push_back(s);
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  vector<int> denkyu_status(M, 0);
  for (int i = 0; i < 1 << N; i++) {
    for (int j = 0; j < N; j++) {
      if ((i >> j & 1) == 1) {
        for (int k = 0; k < M; k++) {
          bool flag2 = false;
          for (int ind = 0; ind < S[k].size(); ind++) {
            if (S[k][ind] == j + 1) {
              flag2 = true;
            }
          }
          if (flag2) {
            denkyu_status[k]++;
          }
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (denkyu_status[j] % 2 != p[j]) {
        flag = false;
      }
    }
    if (flag) {
      ans++;
    }
    for (int k = 0; k < M; k++) {
      denkyu_status[k] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
