import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val ki = Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = in.readLine.split(" ").map(_.toInt)

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

  def dfsEnum(d:Int, n:Int):Int = {
    // d進 n個列挙
    val graph = Array.fill(m)(mu.ListBuffer.empty[Int])
    val enum = Array.ofDim[Boolean](n)
    var ret = 0

    // initialize
    for {
      i <- 0 until m
      j <- ki(i)(0) to 1 by -1
    } (ki(i)(j) - 1) +=: graph(i)
  
    def evalute():Unit = {
      val res = (0 until m)
        .map(i => graph(i).count(enum(_) == true) % 2 == p(i))
        .forall(_ == true)

      if(res) 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
  }

}