import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)

  val graph = Array.ofDim[Boolean](m,n)
  val ki = Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt - 1))
    .toArray
  val p = in.readLine.split(" ").map(_.toInt)

  for {
    i <- 0 until m
    j <- 0 until ki(i)(0) + 1
  } {
    graph(i)(ki(i)(j)) = true
  }

  val ans = dfsEnum(2,n)
  println(ans)

  def dfsEnum(d:Int, n:Int):Int = {
    // d進 n個列挙
    val enum = Array.ofDim[Boolean](n)
    var ret = 0
  
    def evalute():Unit = {
      val res = for(i <- 0 until m) yield {
        val cnt = (0 until n)
        .map(j => if(graph(i)(j) && enum(j)) 1 else 0)
        .sum
        if(cnt == 0) false else cnt % 2 == p(i)
      }
      if(res.forall(_ == true)) ret += 1
    }
  
    def dfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(b <- List(false, true)) {
          enum(cnt) = b
          dfs(cnt+1)
        }
      }
    }
  
    dfs(0)
    ret
  }

}