#include <bits/stdc++.h>
using ll = long long;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vd = std::vector<double>;
using vvd = std::vector<vd>;
using qi = std::queue<int>;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;
const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const ll INF = 10241024;
long double INFD = 100100100;
template <class T1, class T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <class T1, class T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <class T1, class T2>
inline void Abs(T1 &a) {
  a > 0 ? a : -a;
}
template <class T1, class T2>
void update(T1 &a, T2 b) {
  a += b;
  if (a > Mod) a %= Mod;
}
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
  cin >> first;
  IN(rest...);
  return;
}
inline void OUT(void) {
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void OUT(First first, Rest... rest) {
  cout << first << " ";
  OUT(rest...);
  return;
}
int n, m;
vvi vec;
vi modv;
void input() {
  IN(n, m);
  vec.resize(n);
  modv.resize(m);
  for (int(i) = 0; (i) < (m); (i)++) {
    int a;
    IN(a);
    for (int(j) = 0; (j) < (a); (j)++) {
      int b;
      IN(b);
      b--;
      vec[b].push_back(i);
    }
  }
  for (int(i) = 0; (i) < (m); (i)++) {
    IN(modv[i]);
  }
}
void solve() {
  input();
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vi res(m);
    bool ok = true;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        for (auto c : vec[j]) {
          res[c]++;
        }
      }
    }
    for (int j = 0; j < m; j++) {
      res[j] %= 2;
      if (res[j] != modv[j]) {
        break;
        ok = false;
      }
    }
    if (ok) ans++;
  }
  OUT(ans);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
