import java.util.*

fun main(args: Array<String?>) {
    val scanner = Scanner(System.`in`)

    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val flags = IntArray(m)
    for (i in 0 until m) {
        val k = scanner.nextInt()
        var flag = 0;
        for (j in 0 until k) {
            val s = scanner.nextInt()
            flag = flag or (1 shl s - 1)
        }
        flags[i] = flag
    }
    val ps = IntArray(m)
    for (i in 0 until m) {
        ps[i] = scanner.nextInt()
    }
    val end = 1 shl n
    var count = 0
    for (i in 0 until end) {
        var ok = true
        for (j in 0 until m) {
            if (Integer.bitCount(i and flags[j]) % 2 != ps[j]) {
                ok = false
                break
            }
        }
        if (ok) {
            ++count
        }
    }
    println(count)
}
