#include <bits/stdc++.h>
using namespace std;
long long inf = 1000000007;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> s(m);
  int k;
  for (int i = 0; i < m; i++) {
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
    }
  }
  vector<long long> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      long long count = 0;
      for (int id : s[j]) {
        if (bit & (1 << id)) {
          count++;
        }
      }
      if (count % 2 != p[j]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
