fun main() {
    var nm=readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var ks:MutableList<List<Int>> = List(nm[1]){ List(0){0} }.toMutableList()
    for (i in 0 until nm[1]){
        ks[i]= readLine()!!.split(" ").map { it.toInt() }
    }
    var p= readLine()!!.split(" ").map { it.toInt() }

    var ans=0
    for (i in 0 until Math.pow(2.toDouble(), nm[0].toDouble()).toInt()){
        var tmp1=true
        for (j in 0 until nm[1]){
            var tmp2=0
            for (k in 1 .. ks[j][0]){
                if(i.shr(ks[j][k]-1)%2==1) tmp2++
            }
            if (tmp2%2!=p[j]) tmp1=false
        }
        if (tmp1) ans++
    }
    println(ans)
}