#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long N, M;
  cin >> N >> M;
  vector<long long> k(M);
  vector<vector<long long>> s(10);
  for (int j = 0; j < (int)(M); j++) {
    cin >> k[j];
    for (int i = 0; i < (int)(k[j]); i++) {
      long long tmp;
      cin >> tmp;
      s[j].push_back(tmp - 1);
    }
  }
  vector<long long> p(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> p[i];
  };
  ;
  ;
  ;
  long long ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        S.push_back(i);
      }
    }
    if (bit == 0) continue;
    ;
    long long mid_ans = 0;
    for (int i = 0; i < (int)(M); i++) {
      long long counter = 0;
      ;
      for (auto u : s[i]) {
        ;
        if (binary_search(S.begin(), S.end(), u)) {
          counter++;
        }
      };
      if (counter % 2 == p[i]) mid_ans++;
    }
    if (mid_ans == M) {
      ans++;
      ;
    };
  }
  cout << ans << endl;
  return 0;
}
