fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val S = Array(M) { readLine()!!.split(" ").map(String::toInt).drop(1) }
    val P = readLine()!!.split(" ").map(String::toInt)

    var result = 0

    fun check(switches: BooleanArray): Boolean {
        var flg = true
        for ((i, s) in S.withIndex()) {
            val on = s.filter { switches[it - 1] }.size
            if (on % 2 != P[i]) {
                flg = false
                break
            }
        }
        return flg
    }

    fun dfs(i: Int, switches: BooleanArray) {
        if (N == i) {
            if (check(switches)) {
                result++
            }
            return
        }
        switches[i] = true
        dfs(i + 1, switches)
        switches[i] = false
        dfs(i + 1, switches)
    }

    dfs(0, BooleanArray(N))

    println(result)

}

