fun main(args: Array<String>) = println(run {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val s = (1..m).map { readLine()!!.split(" ").map { it.toInt() }.drop(1) }
    val p = readLine()!!.split(" ").map { it.toInt() }

    fun ok(pattern: Int): Boolean {
        val switch = (0 until n).map { pattern.shr(it).and(1) == 1 }
        val light = s.map { it.count { i -> switch[i-1] } }
                .mapIndexed { i, count -> count % 2 == p[i] }
        return light.all { it }
    }

    (0 until 1.shl(n)).count { ok(it) }
})