#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, e, f, g, h, i, j, n, m, l, sum = 0;
  int z[10], k[10], s[10][10], p[10];
  long long aa, bb;
  cin >> n >> m;
  a = m;
  for (i = 0; i < m; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (i = 0; i < m; i++) cin >> p[i];
  for (i = 0; i < pow(2, a); i++) {
    b = i;
    for (j = 0; j < a; j++) {
      if (b >= pow(2, a - 1 - j)) {
        z[j] = 1;
        b = b - pow(2, a - 1 - j);
      } else
        z[j] = 0;
    }
    e = 0;
    do {
      h = 0;
      for (f = 0; f < k[e]; f++) {
        g = s[e][f];
        h = h + z[g];
      }
      e++;
    } while (h % 2 == p[e - 1] && e < m);
    if (h % 2 == p[e - 1]) sum = sum + 1;
  }
  cout << sum;
  return 0;
}
