#include <bits/stdc++.h>
using namespace std;
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}
long long int N, M;
vector<long long int> sw;
vector<long long int> p;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  sw.resize(M);
  for (long long int i = 0; i < M; i++) {
    long long int k;
    cin >> k;
    vector<long long int> s(k);
    for (long long int j = 0; j < k; j++) {
      cin >> s.at(j);
    }
    long long int bits = 0;
    long long int cur = 1;
    long long int j = 0;
    for (long long int t = 0; t < N; t++) {
      if (s.at(j) - 1 == t) {
        bits |= cur;
        j++;
        if ((long long int)(s.size()) == j) break;
      }
      cur <<= 1;
    }
    sw.at(i) = bits;
    ;
  }
  p.resize(M);
  for (long long int i = 0; i < M; i++) {
    cin >> p.at(i);
  }
  long long int answer = 0;
  for (long long int k = 0; k < (1 << N); k++) {
    bool ok = true;
    for (long long int i = 0; i < M; i++) {
      long long int oo = k & sw[i];
      long long int cnt = 0;
      for (long long int q = 0; q < N; q++) {
        if ((1 << q) & oo) cnt++;
      };
      if (cnt % 2 != p.at(i)) {
        ok = false;
        break;
      }
    }
    if (ok) answer++;
  }
  cout << answer << endl;
  return 0;
}
