import scala.io.StdIn

object Main {

  def main(args: Array[String]) {

    val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)
    val kss: Seq[Seq[Int]] =
      Seq() +: (1 to m).map(_ => StdIn.readLine().split(' ').toSeq.map(_.toInt))
    val ps: Seq[Int] = 0 +: StdIn.readLine().split(' ').toSeq.map(_.toInt)

    println(solve(n, m, kss, ps))

  }

  def solve(n: Int, m: Int, kss: Seq[Seq[Int]], ps: Seq[Int]): Int = {
    searchAndCount(n, Seq(), m, kss, ps)
  }

  def searchAndCount(n: Int, onOff: Seq[Int], m: Int, kss: Seq[Seq[Int]], ps: Seq[Int]): Int  = {
    if (n == 0) {
      if (checkBulbs(m, 0 +: onOff, kss, ps)) 1 else 0
    } else {
      val caseOn = searchAndCount(n - 1, 1 +: onOff, m, kss, ps)
      val caseOff = searchAndCount(n - 1, 0 +: onOff, m, kss, ps)
      caseOn + caseOff
    }
  }

  def checkBulbs(m: Int, onOff: Seq[Int], kss: Seq[Seq[Int]], ps: Seq[Int]): Boolean = {
    (1 to m).foldLeft(true)((sum, i) => sum && checkBulb(i, onOff, kss, ps))
  }

  def checkBulb(i: Int, onOff: Seq[Int], kss: Seq[Seq[Int]], ps: Seq[Int]) = {
    val sumOn = kss(i).tail.foldLeft(0)((sum, si) => sum + onOff(si))
    sumOn % 2 == ps(i)
  }

}
