#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> sl(m);
  int s, k;
  for (int i = 0; i < (m); ++i) {
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      cin >> s;
      sl[i].insert(s - 1);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  ll ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    vector<int> sw(m);
    for (int j = 0; j < (n); ++j)
      if (i & 1 << j) sw[j] = 1;
    bool ok = true;
    for (int j = 0; j < (m); ++j) {
      int on = 0;
      for (auto c : sl[j])
        if (sw[c] == 1) on++;
      if (on % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
