#include <bits/stdc++.h>
using namespace std;
int main() {
  static int N, M;
  cin >> N >> M;
  static vector<vector<int>> K(M);
  for (int i = 0; i < (M); i++) {
    static int k;
    cin >> k;
    K[i].resize(k);
    for (int j = 0; j < (k); j++) {
      cin >> K[i][j];
    }
  }
  static vector<int> p(M);
  for (int i = 0; i < (M); i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    int on = 0;
    for (int i = 0; i < (M); i++) {
      int cnt = 0;
      for (int j = 0; j < K[i].size(); j++) {
        if (bit & (1 << j)) {
          cnt++;
        }
      }
      if (cnt % 2 == p[i]) {
        on++;
      }
    }
    if (on == M) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
