#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long s[n][m];
  long long light[m];
  long long p[m];
  fill((long long*)light, (long long*)light + m, 0);
  fill((long long*)s, (long long*)s + n * m, 0);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      s[tmp - 1][i] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        for (int j = 0; j < m; j++) {
          light[j] += s[i][j];
        }
      }
    }
    bool f = true;
    for (int i = 0; i < m; i++) {
      if (light[i] % 2 == p[i]) f = false;
    }
    if (f) {
      ans++;
    }
  }
  cout << ans << endl;
}
