#include <bits/stdc++.h>
using namespace std;
long long longinf = 1ll << 60;
int inf = 1 << 29;
int main() {
  int n, m;
  cin >> n >> m;
  int N = 1 << n;
  int k[m];
  int s[11][11];
  fill(s[0], s[11], 0);
  for (long long l = (long long)0ll; l < (long long)m; l++) {
    cin >> k[l];
    for (long long j = (long long)0ll; j < (long long)k[l]; j++) {
      int a;
      cin >> a;
      a--;
      s[l][j] = a;
    }
  }
  int p[m];
  for (long long i = (long long)0ll; i < (long long)m; i++) cin >> p[i];
  long long ans = 0;
  for (long long st = (long long)0ll; st < (long long)N; st++) {
    int pos[m];
    fill(pos, pos + n, 0);
    for (long long i = (long long)0ll; i < (long long)m; i++) {
      for (long long j = (long long)0ll; j < (long long)k[i]; j++) {
        if (((st >> i) & 1) && s[i][j] == i) {
          pos[i]++;
        }
      }
    }
    bool ok = true;
    for (long long l = (long long)0ll; l < (long long)m; l++) {
      if ((pos[l] & 1) != p[l]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
