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

    var count=0
    for(bit in 0 until 1.shl(n)){
        val switch = BooleanArray(n){bit.shr(it).and(1)==1}
        val init = p.map { it==0 }.toBooleanArray()
        for(i in s.indices) {
            s[i].forEach {
                init[i] = init[i].xor(switch[it])
            }
        }
        if(init.all { it })count++
    }
    println(count)

}