import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto nm = readNums!int;
  auto ks = new int[][](nm[1]);

  foreach(i; 0 .. nm[1]){
    ks[i] ~= readNums!int;
  }

  auto p = readNums!int;
  int cnt;

  for(int i = 0; i < 1<<nm[0]; i++){
    int[] search;
    for(int j = 0; j < nm[0]; j++){
      if(i & (1 << j)){
        search ~= j + 1;
      }
    }
    for(int j = 0; j < nm[1]; j++){
      int c;
      for(int k = 1; k <= ks[j][0]; k++){
        if(canFind(search, ks[j][k])){
          c++;
        }
      }
      if(c % 2 != p[j]) break;
      if(j == nm[1]-1) {
        cnt++;
      }
    }
  }

  writeln(cnt);
}
