#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long s, b;
  cin >> s >> b;
  vector<long long> swich[s];
  for (long long i = 0; i < b; i++) {
    long long k;
    cin >> k;
    while (k--) {
      long long x;
      cin >> x;
      x--;
      swich[x].push_back(i);
    }
  }
  vector<long long> p(s);
  for (long long &i : p) cin >> i;
  long long nos = 1 << s;
  long long ans = 0;
  for (long long i = 0; i < nos; i++) {
    vector<long long> state(s, 0), bulb_ON(b, 0);
    long long temp = i, j = 0;
    while (temp > 0) {
      if (temp & 1) state[j] = 1;
      j++;
      temp >>= 1;
    }
    for (long long j = 0; j < s; j++) {
      if (state[j]) {
        for (long long bulb : swich[j]) bulb_ON[bulb]++;
      }
    }
    long long cnt = 0;
    for (long long j = 0; j < b; j++) cnt += (bulb_ON[j] % 2 == p[j]);
    ans += (cnt == b);
  }
  cout << ans << "\n";
}
