fun main(args: Array<String>) {
    val (n, m) = readIntegerList()
    val lampInfoArray = Array(m) { readIntegerList() }
    val pList = readIntegerList()

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

    println(ans)
}

fun isAllOn(switchState: Int, n: Int, m: Int, lampInfoArray: Array<List<Int>>, pList: List<Int>): Boolean {
    for (i in 0 until m) {
        if (isOff(switchState, lampInfoArray[i], pList[i])) {
            return false
        }
    }

    return true
}

fun isOff(switchState: Int, lampInfo: List<Int>, p: Int): Boolean {
    var count = 0
    for (i in lampInfo.drop(1)) {
        if (((switchState shr (i - 1)) and 1) == 1) {
            count++
        }
    }

    return if ((count % 2) == p) false else 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)
