#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int N, M, k, S, P, ans;
bool flag;
int main() {
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  cin >> N >> M;
  vector<int> s[M];
  int p[M], cnt[M];
  for (int i = 0; i < (int)(M); i++) {
    cin >> k;
    for (int j = 0; j < (int)(k); j++) {
      cin >> S;
      S--;
      s[i].push_back(S);
    }
  }
  for (int i = 0; i < (int)(M); i++) {
    cin >> p[i];
  }
  for (int i = 0; i < (int)((1 << N)); i++) {
    flag = true;
    for (int j = 0; j < (int)(M); j++) {
      cnt[j] = 0;
    }
    bitset<10> bs(i);
    for (int j = 0; j < (int)(M); j++) {
      for (auto x : s[j]) {
        if (bs[x]) cnt[j]++;
      }
      if (cnt[j] % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
