#include <bits/stdc++.h>
using namespace std;
vector<set<long long>> bulb(11, set<long long>());
vector<long long> sub[1 << 11];
vector<long long> p(11, 0);
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long item;
      cin >> item;
      bulb[i + 1].insert(item);
    }
  }
  for (long long i = 0; i < (1 << n); i++) {
    vector<long long> temp;
    for (long long j = 0; j < n; j++) {
      if (!(i & (1 << j))) temp.push_back(j + 1);
    }
    if (temp.size()) sub[i] = temp, temp.clear();
  }
  for (long long i = 0; i < m; i++) cin >> p[i + 1];
  long long ans = 0;
  for (long long i = 0; i < (1 << n); i++) {
    if (sub[i].size()) {
      vector<long long> cnt(11, 0);
      for (long long x : sub[i]) {
        for (long long cx = 1; cx < m + 1; cx++) {
          if (bulb[cx].count(x)) {
            cnt[cx]++;
          }
        }
      }
      long long ctr = 0;
      for (long long z = 1; z < m + 1; z++)
        if ((cnt[z] % 2) == p[z]) ctr++;
      if (ctr == m) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
