import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, m) = listOfInt()
    val bulbFlags = Array(m){ listOfInt().drop(1) }.map { toFlags(n, it) }
    val pp = listOfInt()

    var ans = 0

    for (i in 0 until Math.pow(2.toDouble(), n.toDouble()).toInt()) {
        var failed = false

        for (j in 0 until m) {
            val on = toBinary((i and bulbFlags[j]), "").count { it == '1' }
            if (pp[j] == 0 && on % 2 != 0) failed = true
            if (pp[j] == 1 && on % 2 != 1) failed = true
        }

        if (!failed) ans++
    }

    println(ans)
}

fun toFlags(digit: Int, list: List<Int>): Int {
    val flags = Array(digit){'0'}
    list.forEach {
        flags[it-1] = '1'
    }
    return flags.reversed().joinToString("").toInt()
}

fun toBinary(decimalNumber: Int, binaryString: String = "") : String {
    if (decimalNumber > 0) {
        val temp = "${binaryString}${decimalNumber%2}"
        return toBinary(decimalNumber/2, temp)
    }
    return binaryString.reversed()
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}