#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      S[i].push_back(s);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 1; i < (1 << N); i++) {
    int n = i;
    vector<bool> on(N, false);
    for (int j = 0; j < N; j++) {
      if (n % 2 == 1) {
        on[j] = true;
      }
      n /= 2;
    }
    bool ok = true;
    for (int m = 0; m < M; m++) {
      int cnt = 0;
      for (int s : S[m]) {
        if (on[s]) {
          cnt++;
        }
      }
      if (cnt % 2 != p[m]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
