#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  long long count = 0LL;
  vector<vector<int>> v(N, vector<int>(M, 0));
  vector<int> K(M);
  for (int i = 0; i < M; ++i) {
    cin >> K[i];
    for (int j = 0; j < K[i]; ++j) {
      cin >> v[i][j];
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) {
    cin >> p[i];
  }
  for (int i = 0; i < (1 << N); ++i) {
    vector<int> tmp;
    for (int j = 0; j < N; ++j) {
      if (i & (1 << j)) tmp.push_back(j);
    }
    for (int j = 0; j < M; ++j) {
      int tmp2 = 0;
      for (int k = 0; k < M; ++k) {
        for (int l = 0; l < tmp.size(); ++l) {
          if (v[j][k] == tmp[l]) tmp2++;
        }
      }
      if (tmp2 % 2 != p[j])
        break;
      else if (j == M - 1 && tmp2 % 2 == p[j])
        count++;
    }
  }
  cout << count << endl;
}
