#include <iostream>
#include <cmath>

using namespace std;

//13 = 1101

void binary(int *a, int n, int count){
  int i = 0;
  int m = n;
  while(n > 0){
    a[i] = n%2;
    n /= 2;
    i++;
  }
  //cout << "n=" << m <<endl;
  for(i=0; i<count; i++)
    if(a[i] == -1)
      a[i] = 0;
  /*for(i=0; i<count; i++)
    cout << a[i] << " " ;
    cout << endl;*/
}


void initialization(int *a, int num){
  for(int i=0; i<num; i++)
    a[i] = 0;
}


int main(){
  int N, M;
  cin >> N >> M;
  int k[M];
  int s[M][N];
  int i, j, l;
  for(i=0; i<M; i++){
    cin >> k[i];
    for(j=0; j<k[i]; j++)
      cin >> s[i][j];
  }
  int p[M];
  for(i=0; i<M; i++)
    cin >> p[i];

  int count = 0;
  int count_on[M] = {0};
  int bit_arr[10];
  int all_on_flag = 0;
  for(i=0; i<pow(2, N); i++){
    //bit_arr[]を-1で初期化する
    initialization(bit_arr, 10);
    initialization(count_on, M);
    //iを二進数表記でbit_arrに格納する
    binary(bit_arr, i, pow(2, N) );
    //電球jを見ていく
    for(j=0; j<M; j++){
      //電球jに接続されたスイッチlを見ていく
      for(l=0; l<k[j] ; l++)
	if(bit_arr[ s[j][l]-1 ] == 1){
	  count_on[j]++;
	  //cout << "電球"<<j+1 << " : スイッチ" <<s[j][l]<< endl;
	}
      if(count_on[j]%2 == p[j])
	continue;
      else
	break;
    }
    if(j == M && count_on[j-1]%2 == p[j-1])
      count++;
  }

  cout << count << endl;
    
  return 0;
}
