fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val s: List<Set<Int>> = (1..m).map {
        val k = sc.nextInt()
        sc.asSequence().take(k).map(String::toInt).map { it - 1 }.toSet()
    }
    val p = sc.asSequence().take(m).map(String::toInt).toList()

    val ret = (1 until (1 shl n)).asSequence().count { bits ->
        s.withIndex().all { e ->
            val (idx, ss) = e
            val onCnt = (0 until n).filter { ss.contains(it) }.count { b -> (1 shl b) and bits != 0 }
            onCnt % 2 == p[idx]
        }
    }
    println(ret)
}
