#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N,M; cin >> N >> M; int cnt = 0; vector<int> to(N);
  
  for(int i = 0; i < M; i++){
    int k ; cin >> k;
    for(int j = 0; j < k; j++){
      int s; cin >> s; s--; to[s] |= 1 << i;}}
  
  int p = 0;
  
  for(int j = 0; j < M; j++){
    int c; cin >> c; p |= c << j;}
  
 
  for(int s = 0; s < (1 << N); s++){
    int t = 0;//initialize
    for(int i = 0; i < N; i++){
      if( s >> i & 1){ t ^= to[i];}}
    if( t == p){ cnt++;}}
  
  cout << cnt << endl;
  
  return 0;
}
