#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  int N, M, ks[(10)], xss[(10)][(10)], ps[(10)];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &ks[i]);
    for (int j = 0; j < N; j++) {
      scanf("%d", &xss[i][j]);
      xss[i][j]--;
    }
  }
  for (int i = 0; i < M; i++) {
    scanf("%d", &ps[i]);
  }
  int ans = 0;
  for (int S = 0; S < (1 << N); S++) {
    int is_all_on = 1;
    for (int i = 0; i < M; i++) {
      const int k = ks[i], p = ps[i];
      int num = 0;
      for (int l = 0; l < k; l++) {
        const int x = xss[i][l];
        if ((S & (1 << x)) != 0) {
          num++;
        }
      }
      if (num % 2 != p) {
        is_all_on = 0;
        break;
      }
    }
    if (is_all_on) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
