#include <bits/stdc++.h>
using namespace std;
int main() {
  int M, N, j, b, max, k, an, a;
  j = 0;
  an = 0;
  a = 0;
  cin >> N >> M;
  int d[10][10];
  int pi[N];
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int u = 0; u < k; u++) {
      cin >> d[i][u];
    }
  }
  for (int u = 0; u < M; u++) {
    cin >> pi[u];
  }
  int ans[11];
  for (int i = 0; i < pow(2, N); i++) {
    ans[1] = i % 2;
    ans[2] = (i / 2) % 2;
    ans[3] = (i / 4) % 2;
    ans[4] = (i / 8) % 2;
    ans[5] = (i / 16) % 2;
    ans[6] = (i / 32) % 2;
    ans[7] = (i / 64) % 2;
    ans[8] = (i / 128) % 2;
    ans[9] = (i / 256) % 2;
    ans[10] = (i / 512) % 2;
    for (int p = 0; p < M; p++) {
      for (int u = 0; u < 10; u++) {
        an += ans[d[p][u]];
      }
      if (an % 2 == pi[p]) {
        if (p != M - 1) {
          an = 0;
          continue;
        } else {
          an = 0;
          a++;
          break;
        }
      } else {
        an = 0;
        break;
      }
    }
  }
  cout << a << endl;
}
