#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  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 tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < 1 << N; ++bit) {
    vector<int> tmp;
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) tmp.push_back(i + 1);
    }
    int cnt = 0;
    int flag = true;
    for (int i = 0; i < M; ++i) {
      for (int j : s[i])
        if (find(tmp.begin(), tmp.end(), j) != tmp.end()) cnt += 1;
      if (cnt % 2 != p[i]) flag = false;
    }
    if (flag) ans += 1;
  }
  cout << ans << endl;
  return 0;
}
