#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int s[100][100];
int main() {
  int n, m;
  long long ans = 0;
  cin >> n >> m;
  int k[m];
  for (int i = (int)0; i < (int)m; ++i) {
    cin >> k[i];
    for (int j = (int)0; j < (int)k[i]; ++j) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  int p[m];
  for (int i = (int)0; i < (int)m; ++i) cin >> p[i];
  for (int bit = 0; bit < (1 << m); ++bit) {
    int on[m];
    for (int k = (int)0; k < (int)m; ++k) on[k] = false;
    for (int i = 0; i < m; ++i) {
      if (bit & (1 << i)) {
        on[i]++;
      }
    }
    bool ok = true;
    for (int i = (int)0; i < (int)m; ++i) {
      int cnt = 0;
      for (int l = (int)0; l < (int)k[i]; ++l) {
        if (on[s[i][l]] > 0) cnt++;
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
