#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  static long long s[20][20];
  fill(s[0], s[19] + 20, -1);
  for (long long i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  static long long p[20];
  for (long long i = 0; i < m; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (long long i = 0; i < (1 << n); i++) {
    vector<long long> v(m, 0);
    for (long long j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        for (long long k = 0; k < m; k++) {
          v[k] += s[k][j] != -1;
        }
      }
    }
    bool judge = true;
    for (long long j = 0; j < m; j++) {
      if (v[j] % 2 != p[j]) judge = false;
    }
    if (judge) ans++;
  }
  cout << ans << endl;
  return 0;
}
