import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val s = (0 until m).map { 
        (0 until sc.nextInt()).map { sc.nextInt() - 1 }
    }
    val p = (0 until m).map { 
        sc.nextInt()
    }

    abc128c(n, m, s, p)
}

fun abc128c(n: Int, m: Int, s: List<List<Int>>, p: List<Int>) {
    var ans = 0
    for (bit in 0 until (1.shl(n))) {
        var ok = true
        for (i in 0 until m) {
            var con = 0
            for (si in s.get(i)) {
                if (bit and 1.shl(si) != 0) con++
            }
            if (con % 2 != p.get(i)) ok = false
        }
        if (ok) ans++
    }

    println(ans)
}
