#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
constexpr int N = 11;
int mask[N], p[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int a;
      cin >> a;
      a -= 1;
      mask[i] |= 1 << a;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      int msk = (mask[j] & i);
      int n_on = __builtin_popcount(msk);
      if ((n_on & 1) == p[j]) cnt++;
    }
    if (cnt == m) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
