import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    var s = Array(m) {ArrayList<Int>()}
    for(i in 0 until m){
        val k = readLine()!!.split(" ").map{it.toInt()}
        for(j in 1 .. k[0]) s[i].add(k[j])
    }
    val p = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    for(mask in 0 until (1 shl n)){
        var ok = true
        for(i in 0 until m){
            var cnt = 0
            for(j in 0 until s[i].size){
                if(((mask shr (s[i][j] - 1)) and 1) == 1){
                    cnt++
                }
            }
            if(cnt % 2 != p[i]) ok = false
        }
        if(ok) ans++
    }
    println(ans)
}
