#include <bits/stdc++.h>
const long long INF = 1e15;
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  bool conn[m][n];
  vector<long long> p(m);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) conn[i][j] = false;
  for (int i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      long long s;
      cin >> s;
      conn[i][s] = true;
    }
  }
  for (int i = 0; i < m; i++) {
    long long P;
    cin >> P;
    p[i] = P;
  }
  long long ans = 0;
  long long cnt[m];
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int j = 0; j < m; j++) {
      cnt[j] = 0;
      for (int k = 0; k < n; k++) {
        if ((bit & (1 << k)) && conn[j][k]) cnt[j]++;
      }
    }
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (cnt[j] % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
