#include <bits/stdc++.h>
using namespace std;
template <typename T>
void cout_vector(vector<T> A) {
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  vector<int> P(M);
  vector<int> K(M);
  int ans = 0;
  for (int i = 0; i < (int)(M); i++) {
    int k;
    cin >> k;
    vector<int> s(k);
    for (int j = 0; j < (int)(k); j++) cin >> s[j];
    S[i] = s;
  }
  for (int i = 0; i < (int)(M); i++) cin >> P[i];
  for (int bit = 0; bit < N * N; bit++) {
    bool flag = true;
    vector<int> True_switch;
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        True_switch.push_back(i + 1);
      }
    }
    int m = 0;
    for (int k = 0; k < (int)(M); k++) {
      int on_count = 0;
      for (int s : S[k]) {
        for (int t : True_switch) {
          if (s == t) on_count++;
        }
      }
      flag = (on_count % 2 == P[k]);
      if (!(flag)) break;
      m++;
    }
    (m == M) && (ans++);
  }
  cout << ans << endl;
  return 0;
}
