#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1 << 30;
const long long LINF = 1LL << 58;
const int mod = 1000000007;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> S[m];
  vector<int> pair<int, int>(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[j].push_back(s - 1);
    }
  }
  for (int i = 0; i < m; i++) cin >> pair<int, int>[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    int i = bit;
    for (int j = 0; j < m; j++) {
      int on = 0;
      for (auto v : S[j])
        if (i & (1 << v)) on++;
      if (on % 2 != pair<int, int>[j]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
