#include <cstdio>

unsigned int sw[10];
unsigned int p[10];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; ++j)
    {
      int a;
      scanf("%d", &a);
      sw[i] |= 1 << (a - 1);
    }
  }
  for (int i = 0; i < m; ++i)
  {
    scanf("%d", p + i);
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i)
  {
    int f = 0;
    for (int j = 0; j < m; ++j)
    {
      if ((__builtin_popcount(i & sw[j]) & 1) == p[j]) ++f;
    }
    if (f == m) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}