#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int> > s(M);
  for (int i = 0; i < N; i++) {
    int ktemp;
    cin >> ktemp;
    s[i].resize(ktemp);
    for (int j = 0; j < ktemp; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int temp, chk, cnt = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    chk = 1;
    for (int i = 0; i < M; i++) {
      temp = 0;
      for (int j = 0; j < k[i]; j++)
        if ((bit >> s[i][j]) & 1) temp++;
      if (temp % 2 != p[i]) {
        chk = 0;
        break;
      }
    }
    if (chk) cnt++;
  }
  cout << cnt << endl;
}
