import scala.io.StdIn._
object Main extends App {

  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val switchesOfLight: Seq[Array[Int]] = Seq.fill(m)(readLine().split(" ").drop(1).map(_.toInt - 1))
  val conds: Array[Int] = readLine().split(" ").map(_.toInt)
  
  val condAndSwitchesSeq: Array[(Int, Array[Int])] = conds zip switchesOfLight

  def solve() = {
    (0 until (1 << n)).count { i =>
      val onLightCount = condAndSwitchesSeq.count { case (cond, switches) =>
        val onSwitchCount = switches.count(isOn(i, _))
        onSwitchCount % 2 == cond
      }
      onLightCount == m
    }
  }

  def isOn(combi: Long, switch: Int) =
    (combi & (1 << switch)) != 0

  println(solve)

}