import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val s = Array(m, { IntArray(n) })
    val p = IntArray(m)
    for (i in 0 until m) {
        val k = scanner.nextInt()
        for (j in 0 until k) s[i][j] = scanner.nextInt()
    }
    for (i in 0 until m) p[i] = scanner.nextInt()
    var cnt = 0
    val sc = IntArray(m)
    val po = Math.pow(2.0, n.toDouble())
    for (i in 0 until po.toInt()) {
        sc.fill(0)
        for (j in 0 until n) {
            if (1 and (i shr j) == 1) {
                for (k in 0 until m) {
                    if (s[k].contains(j)) sc[k]++
                }
            }
        }
        for (k in 0 until m) {
            if ((sc[k] % 2) != p[k]) break
            if (k == m - 1) cnt++
        }
    }
    println(cnt)
}
