private fun bits(x: Int): Int {
    var ret = 1
    repeat(x) { ret *= 2 }
    return ret - 1
}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val sList = (1..m).map { readLine()!!.split(" ").drop(1).map { it.toInt() - 1 }.toIntArray() }
    val pList = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var answer = 0
    val bits = bits(n)
    val bitsLength = bits.toString(2).length
    for (i in 0..bits) {
        val lump = i.toString(2).padStart(bitsLength, '0')
        sList.withIndex().all { s -> s.value.count { lump[it] == '1' } % 2 == pList[s.index] }
            .let { if (it) answer++ }
    }

    println(answer)
}

