fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val SW = (0 until M).map { listOfInt().drop(1).map { 1 shl (it - 1) } }
    val P = listOfInt()
    var ans = 0
    for (n in 0 until (1 shl N)) {
//System.err.println(java.lang.Integer.toBinaryString(n))
        var d = 0
        SW.forEachIndexed { index, list ->
            var c = 0
            list.forEach {
//System.err.print("$index ${java.lang.Integer.toBinaryString(it)}")
                if (n and it != 0) c += 1
//System.err.println(" $c")
            }
            if (c % 2 == P[index]) d += 1
        }
//System.err.println(" d:$d")
        if (d == M) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)