#include <bits/stdc++.h>
using namespace std;
using ll = long long;
namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
}  // namespace NS
int N, M;
vector<vector<int>> lightInfo;
vector<int> p;
ll DFS(ll turn, int depth) {
  if (depth == N) {
    turn = turn << 1;
    int cnt = 0;
    for (int i = 0; i < M; ++i) {
      for (auto &&e : lightInfo[i]) {
        if ((turn & (1 << e))) {
          ++cnt;
        }
      }
      if (cnt % 2 != p[i]) {
        return 0;
      }
    }
    return 1;
  }
  return DFS((turn << 1) | 1, depth + 1) + DFS((turn << 1), depth + 1);
}
int main() {
  cin >> N >> M;
  lightInfo.resize(M);
  p.resize(M);
  int k, s;
  for (int i = 0; i < M; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) {
      cin >> s;
      lightInfo[i].push_back(s);
    }
  }
  for (auto &&e : p) {
    cin >> e;
  }
  ll ans = DFS(0, 0);
  cout << ans << endl;
}
