#include <bits/stdc++.h>
using namespace std;
int N, M;
int k[11];
int S[11][11];
int flagS[11];
int p[11];
int main(void) {
  cin >> N >> M;
  vector<vector<int>> vS;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    vector<int> vec;
    for (int j = 0; j < k[i]; j++) {
      cin >> S[i][j];
      vec.push_back(S[i][j]);
      flagS[i] |= (1 << (S[i][j] - 1));
    }
    vS.push_back(vec);
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    vector<int> S;
    bool flag = true;
    for (int i = 0; i < M; i++) {
      if (bit & (1 << i)) {
        S.push_back(i + 1);
      }
    }
    for (int i = 0; i < M; i++) {
      int count = 0;
      for (auto v : S) {
        if (std::find(vS[i].begin(), vS[i].end(), v) != vS[i].end()) {
          count++;
        }
      }
      if (count % 2 != p[i]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
