#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
ll count_digits(ll n) {
  int ans = 0;
  while (n) n /= 10, ans++;
  return ans;
}
int main() {
  int nb, ns, ans = 0, aux, k, cnt;
  bool on;
  bitset<11> b;
  cin >> ns >> nb;
  vector<int> v[11];
  vector<int> resto(nb);
  for (int i = 0; i < nb; i++) {
    cin >> k;
    for (int i = 0; i < k; i++) {
      cin >> aux;
      v[i].push_back(--aux);
    }
  }
  for (auto& x : resto) cin >> x;
  for (int i = 0; i < (1 << ns); i++) {
    b = i;
    on = true;
    for (int j = 0; j < nb; j++) {
      cnt = 0;
      for (auto x : v[j]) cnt += b[x];
      if (cnt % 2 != resto[j]) {
        on = false;
        break;
      }
    }
    if (on) ans++;
  }
  cout << ans << endl;
  return 0;
}
