#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int n, m;
  cin >> n >> m;
  vector<vector<int> > s(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      a--;
      s[i].emplace_back(a);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  auto ans = 0L;
  for (unsigned int bit = 0; bit < (1U << n); ++bit) {
    bool isOK = true;
    for (int i = 0; i < n; ++i) {
      int cnt = 0;
      for (unsigned int v : s[i]) {
        if (bit & (1U << v)) ++cnt;
      }
      if (cnt % 2 != p[i]) isOK = false;
    }
    if (isOK) ++ans;
  }
  cout << ans << endl;
  return 0;
}
