#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
struct __INIT {
  __INIT() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} __init;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    S[i].resize(k);
    for (int j = 0; j < k; j++) cin >> S[i][j];
  }
  vector<int> P(M);
  for (int i = 0; i < M; i++) cin >> P[i];
  ll sum = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool exist = true;
    int on = 0;
    for (int i = 0; i < M; i++) {
      for (int j : S[i]) {
        if (bit & (1 << j)) on++;
      }
      if (on % 2 != P[i]) {
        exist = false;
        break;
      }
    }
    if (exist) sum++;
  }
  cout << sum << endl;
}
