
fun main(args:Array<String>) {
    val (a,b) = readLine()!!.split(" ").map{it.toInt()}
    switchCount = a
    lightCount = b

    switches.addAll((1..lightCount).map { readLine()!!.split(" ").map { it.toInt() - 1 }.drop(1).toMutableList() }.toMutableList())
    lightSetting.addAll(readLine()!!.split(" ").map { it.toInt() })
    val ans = getAns(0,0)
    println(ans)
}
var switchCount = 0
var lightCount = 0
val switches = mutableListOf<MutableList<Int>>()
val lightSetting = mutableListOf<Int>()

fun getAns(idx:Int, subtotal:Int):Int {
    if(idx >= switchCount) {
        var isAll = true
        for(i in lightSetting.indices) {
            var cnt = 0
            for(j in switches[i]) {
                val key = 1 shl j
                if((subtotal and key) != 0) {
                    cnt++
                }
            }
            if(cnt % 2 != lightSetting[i]) {
                isAll = false
            }
        }
        return if(isAll) 1 else 0
    }
    val tmp = (1 shl idx)
    val ans = getAns(idx + 1, subtotal) + getAns(idx + 1, subtotal + tmp)
    return ans
}