fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val s = (1..m).map { readLine()!!.split(' ').drop(1).map(String::toInt) }
    val p = readLine()!!.split(' ').map(String::toInt)
    var cnt = 0
    (0 until Math.pow(2.0, n.toDouble()).toInt()).forEach {
        val onSw = Integer.toString(it, 2).padStart(n, '0').toCharArray()
            .mapIndexed { i, c -> (i + 1) to c }
            .filter { it.second == '1' }
            .map(Pair<Int, Char>::first)
        val t = (0 until m).all { s[it].filter { onSw.contains(it) }.count() % 2 == p[it] }
        if (t) cnt++
    }
    println(cnt)
}
