import java.util.*

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (n, m) = reader.readLine()!!.split(" ").map{it.toInt()}
    val k = Array(m, {
        val x = reader.readLine()!!.split(" ").map{it.toInt()-1}
        x.drop(1)
    })
    val p = reader.readLine()!!.split(" ").map{it.toInt()}

    val res = Array(m, {
        ArrayList<Int>()
    })
    val max = (1 shl n)
    for (i in 0..m-1) {
        for (j in 0..max-1) {
            var cnt = 0
            for (d in 0..n-1) {
                if ((d in k[i]) && (j and (1 shl d) > 0)) {
                    cnt += 1
                }
            }
            if (cnt%2 == p[i]) {
                res[i].add(j)
            }
        }
    }

    var ans = res[0].toSet()
    for (i in 1..m-1) {
        ans = ans.intersect(res[i])
    }
    println(ans.size)
}
