#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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;
}
template <class T>
inline T GCD(T a, T b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
  return (a * b) / GCD(a, b);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int S;
      cin >> S;
      S--;
      s[i].push_back(S);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int count = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int j = 0; j < m; j++) {
      int cnt = 0;
      for (auto v : s[j]) {
        if (bit & (1 << v)) cnt++;
      }
      if (cnt % 2 == p[j]) count++;
    }
  }
  cout << count << endl;
}
