#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  vector<int> p(M);
  vector<int> k(M);
  for (int i = 0; i < (M); i++) {
    cin >> k[i];
    s[i].resize(k[i]);
    for (int j = 0; j < (k[i]); j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < (M); i++) cin >> p[i];
  long long pattern = pow(2, N);
  vector<int> tmp_s(N, 0);
  int ans = 0;
  for (int i = 0; i < (pattern + 1); i++) {
    bool ok = true;
    for (int j = 0; j < (N); j++) {
      if (i & 1 << (j + 1)) {
        tmp_s[j] = 1;
      } else {
        tmp_s[j] = 0;
      }
    }
    for (int j = 0; j < (M); j++) {
      int cnt = 0;
      for (int l = 0; l < (k[j]); l++) {
        if (tmp_s[s[j][l] - 1]) {
          cnt++;
        }
      }
      if (cnt % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
