#include <bits/stdc++.h>
using namespace std;
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;
}
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
int N, M, k;
int main() {
  cin >> N >> M;
  vector<vector<int> > v(M);
  for (int i = 0; i < (M); ++i) {
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int t;
      cin >> t;
      v[i].push_back(--t);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (M); ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 1; bit < (1 << N); ++bit) {
    vector<int> on;
    for (int i = 0; i < (N); ++i) {
      if (bit & (1 << i)) {
        on.push_back(i);
      }
    }
    bool isok = true;
    for (int i = 0; i < (M); ++i) {
      int cnt = 0;
      for (int j = 0; j < (v[i].size()); ++j) {
        for (int k = 0; k < (on.size()); ++k) {
          if (on[k] == v[i][j]) ++cnt;
        }
      }
      if (cnt % 2 != p[i]) {
        isok = false;
        break;
      }
    }
    if (isok) ++ans;
  }
  cout << ans << endl;
  return 0;
}
