fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val ss = Array(m) { readLine()!!.split(" ").map { Math.pow(2.0, it.toDouble()-1.0).toInt() }.drop(1).sum() }
    val pp = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0L

    outer@for (i in 0 until Math.pow(2.0, n.toDouble()).toInt()) {
        for (j in ss.indices) {
            val bitCnt = Integer.bitCount(i and ss[j])
            if (bitCnt % 2 != pp[j]) continue@outer
        }
        cnt++
    }

    println(cnt)
}