#include <bits/stdc++.h>
using namespace std;
struct Solver {
  void solve() {
    const int NM_MAX = 10;
    int N, M;
    cin >> N >> M;
    vector<bitset<NM_MAX>> cn(M);
    for (int i = 0; i < M; ++i) {
      int k;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        int s;
        cin >> s;
        cn[i][s - 1] = true;
      }
    }
    int p[NM_MAX] = {};
    for (int i = 0; i < M; ++i) {
      cin >> p[i];
    }
    int ans = 0;
    for (int sb = 1; sb < (1 << N); ++sb) {
      int lgt = 0;
      for (int i = 0; i < M; ++i) {
        int onsw = 0;
        for (int j = 0; j < N; ++j) {
          if (sb & (1 << j) && cn[i][j]) {
            onsw += 1;
          }
        }
        lgt += (onsw % 2 == p[i]);
      }
      ans += (lgt == M);
    }
    cout << ans << endl;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solver().solve();
  return 0;
}
