#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
int main() {
  ll N, M;
  cin >> N >> M;
  vllvll s(M, vll(0));
  ll tmp;
  ll k;
  for (long long i = 0; i < M; ++i) {
    cin >> k;
    for (long long j = 0; j < k; ++j) {
      cin >> tmp;
      --tmp;
      s[i].push_back(tmp);
    }
  }
  vll p(M);
  for (long long i = 0; i < M; ++i) {
    cin >> p[i];
  }
  ll ans = 0;
  for (long long bit = 0; bit < 1 << N; ++bit) {
    vll switches(M, 0);
    for (long long i = 0; i < N; ++i) {
      if (bit & 1 << i) {
        switches[i] = 1;
      }
    }
    bool flg = true;
    for (long long i = 0; i < M; ++i) {
      ll sm = 0;
      for (long long j = 0; j < s[i].size(); ++j) {
        sm += switches[s[i][j]];
      }
      if (sm % 2 != p[i]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      ++ans;
    }
  }
  cout << ans << endl;
}
