#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m];
  int s[m][n];
  int p[m];
  for (int i = 0; i < (int)m; i++) {
    cin >> k[i];
    for (int j = 0; j < (int)k[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < (int)m; i++) cin >> p[i];
  for (int i = 0; i < (int)m; i++) {
    for (int j = 0; j < (int)n; j++) s[i][j]--;
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool can = true;
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (auto id : s[i]) {
        if (bit & (1 << id)) count++;
      }
      if ((count % 2) != p[i]) can = false;
    }
    if (can) ans++;
  }
  cout << ans << endl;
  ;
}
