#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;
}
int main() {
  int n, m;
  cin >> n >> m;
  int s[11][11];
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 1; j <= k; j++) {
      int w;
      cin >> w;
      s[i][w] = 1;
    }
  }
  int p[11];
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    int t[11] = {0};
    for (int i = 0; i < n; i++) {
      if (bit & 1 << i) {
        cerr << i + 1 << " ";
        for (int j = 1; j <= m; j++) {
          if (s[j][i + 1] == 1) t[j] += 1;
        }
      }
    }
    bool isok = true;
    for (int i = 1; i <= m; i++) {
      if (t[i] % 2 != p[i]) {
        isok = false;
      }
    }
    if (isok) {
      cerr << "ok";
      ans++;
    }
    cerr << endl;
  }
  cout << ans << endl;
}
