#include <bits/stdc++.h>
using namespace std;
int n, m, ans, mod[102];
vector<int> vec[102];
bool mark(int x) {
  int arr[102];
  memset(arr, 0, sizeof(arr));
  int p = 1, ind = 1;
  while (p <= x) {
    if (p & x) {
      for (int i = 0; i < vec[ind].size(); i++) {
        arr[vec[ind][i]]++;
      }
    }
    p = p << 1;
    ind++;
  }
  bool posible = true;
  for (int i = 0; i < m; i++) {
    if (arr[i] % 2 != mod[i]) {
      posible = false;
    }
  }
  return posible;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0, s; i < m; i++) {
    scanf("%d", &s);
    for (int j = 0, act; j < s; j++) {
      scanf("%d", &act);
      vec[act].push_back(i);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &mod[i]);
  }
  int top = pow(2, n);
  for (int i = 0; i <= top; i++) {
    ans += mark(i);
  }
  printf("%d\n", ans);
  return 0;
}
