import scala.io.{StdIn => in}

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

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

  val res = for {
    i <- 0 until m
  } yield dfsEnum(2, ki(i)(0)+1, p(i))

  // println(res.mkString(" "))

  val ans = res.product
  println(ans)

  def dfsEnum(d:Int, n:Int, p:Int):Int = {
    // d進 n個列挙
    val enum = Array.ofDim[Int](n)
    var ret = 0
  
    def evalute():Unit = {
      // println("e: " + n + " " + enum.count(_ == 1))
      if(!enum.forall(_ == 0) && enum.count(_ == 1) % 2 == p)
        ret += 1
    }
  
    def dfs(cnt:Int):Unit = {
      if(cnt == n) evalute
      else {
        for(i <- 0 until d) {
          enum(cnt) = i
          dfs(cnt+1)
        }
      }
    }
  
    dfs(0)
    ret
  }

}