#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> S(N,0);
  for(int i = 0; i < M; ++i){
    int k;
    cin >> k;
    for(int j = 0; j < k; ++j){
      int t;
      cin >> t;
      --t;
      S[t] |= (1<<i);
    }
  }
  int bit = 0;
  for(int i = 0; i < M; ++i){
    int p;
    cin >> p;
    bit |= p<<i;
  }
  int ans = 0;
  for(int i = 0; i < (1<<N); ++i){
    int t = bit;
    for(int j = 0; j < N; ++j){
      if(not ((i>>j)&1)) continue;
      t ^= S[j];
    }
    if(not t) ++ans;
  }
  cout << ans << endl;
}
