#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M, p;
  cin >> N >> M;
  int k[M];
  int ans = 0;
  vector<vector<int>> stol(10);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int sw;
      cin >> sw;
      stol.at(sw).push_back(i + 1);
    }
  }
  bitset<10> lightall;
  for (int i = 0; i < M; i++) {
    cin >> p;
    if (p) lightall.set(i);
  }
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<10> s(tmp);
    bitset<10> light;
    for (int i = 0; i < N; i++) {
      if (s.test(i)) {
        for (int l : stol.at(i + 1)) light.flip(l - 1);
      }
    }
    if (light == lightall) ans++;
  }
  cout << ans;
}
