import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val kArray = Array(m) { readIntegerList() }
    val pList = readIntegerList()

    var ans = 0
    for (state in 0 until (1 shl n)) {
        if (isAllOn(state, n, m, kArray, pList)) {
            ans++
        }
    }

    println(ans)
}

fun isAllOn(state: Int, n: Int, m: Int, kArray: Array<List<Int>>, pList: List<Int>): Boolean {
    for (i in 0 until m) {
        var onCount = 0
        for (j in 1..kArray[i][0]) {
            if (state and (1 shl (kArray[i][j] - 1)) != 0) {
                onCount++

            }
        }

        if (onCount % 2 != pList[i]){
            return false
        }
    }
    return true
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)
