#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int n, m;
  int num[12][12];
  int p[12];
  int k, c;
  int bitcnt = 0, ans = 0;
  bool chkflag;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) num[i][j] = 0;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &k);
    for (int j = 0; j < k; ++j) {
      scanf("%d", &c);
      num[i][c - 1] = 1;
    }
  }
  for (int i = 0; i < m; ++i) scanf("%d", &p[i]);
  for (int i = 0; i < (1 << n); ++i) {
    chkflag = true;
    for (int j = 0; j < m; ++j) {
      for (int l = 0; l < n; ++l) {
        if (num[j][l] & i >> l) bitcnt += 1;
      }
      if (bitcnt % 2 != p[j]) chkflag = false;
    }
    if (chkflag) ans += 1;
  }
  printf("%d\n", ans);
  return 0;
}
