#include <bits/stdc++.h>
using namespace std;
vector<bool> states;
set<int> bulls;
set<string> combBulls;
string getCombBull(vector<bool> &v) {
  string s = "";
  for (int i = 0; i < v.size(); i++) {
    if (bulls.find(i) != bulls.end()) s += (char)((int)v[i] + '0');
  }
  return s;
}
int checkOns(vector<bool> &v, vector<vector<bool> > &ons) {
  for (int i = 0; i < ons.size(); i++) {
    int st = 0;
    for (int j = 0; j < ons[i].size(); j++) {
      if (v[ons[i][j]]) st++;
    }
    if ((st % 2) != states[i]) return 0;
  }
  return 1;
}
int generatCombs(int n, vector<vector<bool> > &ons) {
  int c = 0;
  string bull;
  for (int i = 0; i <= n; i++) {
    vector<bool> v(n);
    fill(v.end() - i, v.end(), true);
    do {
      bull = getCombBull(v);
      if (combBulls.find(bull) == combBulls.end()) {
        combBulls.insert(bull);
        c += checkOns(v, ons);
      }
    } while (std::next_permutation(v.begin(), v.end()));
  }
  return c;
}
int main() {
  int n, m, k, p, s, i, j, c = 0;
  scanf("%d %d", &n, &m);
  vector<vector<bool> > ons(m);
  for (i = 0; i < m; i++) {
    scanf("%d ", &k);
    for (j = 0; j < k; j++) {
      scanf("%d ", &s);
      ons[i].push_back(s - 1);
      bulls.insert(s - 1);
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d ", &p);
    states.push_back(p);
  }
  printf("%d\n", generatCombs(n, ons));
  return 0;
}
