#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 11;
int n;
int m;
int K[M];
int p[M];
int s[M][M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    K[i] = x;
    for (int j = 1; j <= x; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &p[i]);
  }
  int ways = 0;
  for (int mask = 1; mask < (1 << n); mask++) {
    int ison = 0;
    for (int i = 1; i <= m; i++) {
      int switchesonme = 0;
      for (int j = 1; j <= K[i]; j++) {
        if (mask & (1 << (s[i][j] - 1))) switchesonme++;
      }
      if (p[i] == switchesonme % 2) ison++;
    }
    if (ison == m) ways++;
  }
  printf("%d\n", ways);
}
