fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val switches = (0 until m).map {
        val s = readLine()!!.split(' ').map { it.toInt() }
        s.slice(1 .. s[0]).toSet()
    }
    val ps = readLine()!!.split(' ').map { it.toInt() }

    fun dfs(i: Int, set: Set<Int>): Int {
        if (i == n) {
            val r = (0 until m).all {
                switches[it].intersect(set).size % 2 == ps[it]
            }
            return if (r) {
                1
            } else {
                0
            }
        }
        return dfs(i + 1, set.plus(i + 1)) + dfs(i + 1, set)
    }

    println(dfs(0, emptySet()))
}
