#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int N, M;
array<int, 15> num;
vector<int> K, S[15];
bool P[15];
void solve() {
  for (int i = 0; i < (1 << N); i++) {
    fill(num.begin(), num.end(), 0);
    bitset<10> mask = i;
    for (int j = 0; j < N; j++) {
      if (mask[j]) {
        for (auto &&e : S[j]) {
          num[e]++;
        }
      }
    }
    bool flag = true;
    for (int i = 0, i_len = (M); i < i_len; ++i) {
      if (num[i] % 2 != P[i]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
int main() {
  cin >> N >> M;
  K.resize(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> K[i];
    for (int j = 0, j_len = (K[i]); j < j_len; ++j) {
      int tmp;
      cin >> tmp;
      tmp--;
      S[i].push_back(tmp);
    }
  }
  for (int i = 0, i_len = (M); i < i_len; ++i) cin >> P[i];
  solve();
}
