#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int i, j, l;
  cin >> n >> m;
  int k[m];
  int s[m][n];
  int tmp;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      s[i][j] = 0;
    }
  }
  for (i = 0; i < m; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> tmp;
      s[i][tmp - 1] = 1;
    }
  }
  int p[m];
  for (i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int tmp2, tmp3;
  int flag = 0;
  int s_condition[n];
  int tmp4 = pow(2.0, (double)n);
  for (i = 0; i < tmp4; i++) {
    tmp2 = i;
    tmp3 = 0;
    flag = 1;
    for (j = 0; j < n; j++) {
      s_condition[j] = tmp2 % 2;
      tmp2 = tmp2 / 2;
    }
    for (j = 0; j < m; j++) {
      for (l = 0; l < n; l++) {
        if (s[j][l] == 1 && s_condition[l] == 1) {
          tmp3++;
        }
      }
      if (tmp3 % 2 == p[j]) {
      } else {
        flag = 0;
      }
    }
    if (flag == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
