#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<bool>> s(M, vector<bool>(N, false));
  for (int i = 0; i < (int)(M); i++) {
    cin >> k.at(i);
    for (int j = 0; j < (int)(k.at(i)); j++) {
      int tmp;
      cin >> tmp;
      s.at(i).at(j) = true;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (int)(M); i++) cin >> p.at(i);
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bitset<10> S(i);
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int c = 0;
      for (int l = 0; l < N; l++) {
        if (S.test(l) && s.at(j).at(l)) c++;
      }
      if (c % 2 != p.at(j)) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
