#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
  int from;
  int to;
  int cost;
};
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
struct ed {
  double x;
  double y;
  double l;
  double a;
};
int main() {
  int n, m, k, x;
  cin >> n >> m;
  vector<vector<int> > s(m);
  vector<int> p(m);
  for (int i = 0; i < (m); i++) {
    cin >> k;
    for (int j = 0; j < (k); j++) {
      cin >> x;
      x--;
      s[i].push_back(x);
    }
  }
  for (int i = 0; i < (m); i++) cin >> p[i];
  int cnt = 0;
  for (int i = 0; i < (pow(2, n)); i++) {
    int c = 0;
    for (int j = 0; j < (m); j++) {
      int ktemp = 0;
      for (auto k : s[j]) {
        if ((i & 1 << k) == 1) ktemp++;
      }
      if (ktemp % 2 == p[j]) c++;
    }
    if (c == m) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
