#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e18;
const long long dx4[4] = {1, 0, -1, 0};
const long long dy4[4] = {0, 1, 0, -1};
const long long dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const double pi = acos(-1);
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using Graph = vector<vector<long long>>;
void solve() {
  std::ifstream in("sample.txt");
  std::cin.rdbuf(in.rdbuf());
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long k[20];
  long long s[20][20];
  long long p[20];
  for (long long im = 0; im < m; im++) {
    cin >> k[im];
    for (long long j = 0; j < k[im]; j++) {
      cin >> s[im][j];
      s[im][j]--;
    }
  }
  for (long long i = 0; i < m; i++) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0; bit < (1 << n); bit++) {
    bool isOK = true;
    for (long long im = 0; im < m; im++) {
      long long counter = 0;
      for (long long js = 0; js < k[im]; js++) {
        if ((bit >> js) & 1) counter++;
      }
      if (counter % 2 != p[im]) isOK = false;
      ;
    }
    if (isOK) ans++;
  }
  cout << ans << endl;
}
signed main() {
  solve();
  return 0;
}
