#include <bits/stdc++.h>
using namespace std;
int n, m, k, res;
int p[11], l[11], check[11], a[11][11], id[1025][11];
void inp() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> l[i];
    for (int j = 1; j <= l[i]; ++j) cin >> a[i][j];
  }
  for (int i = 1; i <= m; ++i) cin >> p[i];
}
void prep() {
  k = 1;
  for (int i = 1; i <= n; ++i) k *= 2;
  for (int i = 2; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) id[i][j] = id[i - 1][j];
    id[i][n]++;
    for (int j = n; j > 0; --j) {
      if (id[i][j] > 1) {
        id[i][j - 1]++;
        id[i][j] -= 2;
      }
    }
  }
}
void pc() {
  prep();
  int tmp = res = 0;
  for (int i = 1; i <= k; ++i) {
    int d = tmp = 0;
    for (int j = 1; j <= n; ++j) check[j] = id[i][j];
    for (int j = 1; j <= m; ++j) {
      for (int t = 1; t <= l[j]; ++t)
        if (check[a[j][t]]) d++;
      if (d % 2 == p[j])
        tmp++;
      else
        break;
    }
    if (tmp == m) res++;
  }
  cout << res;
}
int main() {
  inp();
  pc();
  return 0;
}
