fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  val connected = Array(m, { BooleanArray(n) })
  repeat(m) {
    val ss = readLine()!!.split(" ").map { it.toInt() }
    for (i in 1 until ss.size) {
      connected[it][ss[i] - 1] = true
    }
  }
  val ps = readLine()!!.split(" ").map { it.toInt() }

  val ans = (0 until (1 shl n)).count { pattern ->
    val ons = BooleanArray(n, { (pattern and (1 shl it)) != 0 })
    (0 until m).all { lightId ->
      (0 until n).count { switchId -> connected[lightId][switchId] && ons[switchId] } % 2 == ps[lightId]
    }
  }
  println(ans)
}