#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  int k[10], s[10][10], p[10], ans = 0;
  for (int i = (0), i_end_ = (m); i < i_end_; i++) {
    cin >> k[i];
    for (int j = (0), j_end_ = (k[i]); j < j_end_; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = (0), i_end_ = (m); i < i_end_; i++) cin >> p[i];
  int sw[n];
  for (int i = (0), i_end_ = (pow(2, n)); i < i_end_; i++) {
    int fl = i;
    for (int j = (0), j_end_ = (n); j < j_end_; j++) {
      sw[j] = fl % 2;
      fl /= 2;
    }
    for (int j = (0), j_end_ = (m); j < j_end_; j++) {
      int count = 0;
      for (int l = (0), l_end_ = (k[j]); l < l_end_; l++) {
        count += sw[s[j][l] - 1];
      }
      if (count % 2 != 0) break;
      if (j == m - 1) ans++;
    }
  }
  cout << ans << endl;
}
