#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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