#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 10;
int main(int argc, char const *argv[]) {
  int n, m, k[MAX_N], p[MAX_N];
  cin >> n >> m;
  vector<vector<int> > s(m);
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      int si;
      cin >> si;
      si--;
      s[i].emplace_back(si);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bitset<10> bs(i);
    vector<int> switchs;
    for (int j = 0; j < n; ++j) {
      if (bs[j] == 1) {
        switchs.emplace_back(j);
      }
    }
    int cnt = 0;
    for (int j = 0; j < m; ++j) {
      vector<int> vec_inter;
      set_intersection(switchs.begin(), switchs.end(), s[j].begin(), s[j].end(),
                       std::back_inserter(vec_inter));
      if (vec_inter.size() % 2 == p[j]) cnt++;
    }
    if (cnt == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
