import java.util.BitSet

fun main(args: Array<String>) {
    val (n, m) = readInputLine().split(" ").map{it.toInt()}
    
    val switches = mutableListOf<List<Int>>()
    
    for (i in 1..m) {
        val s = readInputLine().split(" ").map{it.toInt() - 1}
        switches.add(s.drop(1))
    }
    
    val p = readInputLine().split(" ").map{it.toInt()}

    println(dfs(0, n, BitSet(n), p, switches))
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(index:Int, n: Int, s: BitSet, p: List<Int>, switches: List<List<Int>>): Int {
    if (index == n) {
        var ok = true
        for ((i, switch) in switches.withIndex()) {
            var on = 0
            for (k in switch) {
                if (s[k]) {
                    on++
                }
            }
            if (on % 2 != p[i]) {
                ok = false
                break
            }
        }
        if (ok) {
            return 1
        } else {
            return 0
        }
    }
    
    var ret = 0
    
    ret += dfs(index + 1, n, s, p, switches)
    
    val newSet = s.clone() as BitSet
    newSet[index] = true
    ret += dfs(index + 1, n, newSet, p, switches)

    return ret
}
