#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
template <typename T>
inline void chmax(T &a, T b) {
  if (a < b) a = b;
  return;
}
template <typename T>
inline void chmin(T &a, T b) {
  if (a > b) a = b;
  return;
}
int k[10];
int s[10][10];
int p[10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; ++i) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int switch_on = 0;
    for (int j = 0; j < m; ++j) {
      int cnt = 0;
      for (int bit = 0; bit < n; ++bit) {
        for (int l = 0; l < k[j]; ++l) {
          if (bit & (1 << i) && (bit + 1) == s[j][l]) ++cnt;
        }
      }
      switch_on += (cnt % 2 == p[j]);
    }
    ans += switch_on == m;
  }
  cout << (ans) << '\n';
  return 0;
}
