#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t n, m;
  int64_t k, s[20][20], p[20], a;
  int64_t ans = 0;
  int64_t r[20] = {};
  cin >> n >> m;
  for (int64_t i = 0; i < m; i++) {
    cin >> k;
    for (int64_t j = 0; j < k; j++) {
      cin >> a;
      s[i][a - 1] = 1;
    }
  }
  for (int64_t i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (int64_t i = 0; i < (1 << n); i++) {
    for (int64_t j = 0; j < n; j++) {
      if (i & (1 << j)) {
        for (int64_t k = 0; k < m; k++) {
          if (s[k][j] == 1) r[k]++;
        }
      }
    }
    bool f = true;
    for (int64_t j = 0; j < m; j++) {
      if (r[j] % 2 != p[j]) {
        f = false;
      }
      r[j] = 0;
    }
    if (f) ans++;
  }
  cout << ans << "\n";
}
