import java.util.*

fun main(args: Array<String>) {
    solve(Scanner(System.`in`))
}

fun pow(a: Int, p: Int): Long = pow(a.toLong(), p)
fun pow(a: Long, p: Int): Long = when {
    p == 0 -> 1L
    p % 2 == 1 -> a * pow(a, p - 1)
    else -> {
        val half = pow(a, p / 2)
        half * half
    }
}

fun bits(n: Int): Int {
    var bits = 0
    for (i in 0..15) {
        if ((1 shl i) and n != 0) {
            bits++
        }
    }
    return bits
}

fun solve(sc: Scanner) {
    val N = sc.nextInt()
    val M = sc.nextInt()
    val S = Array(M) {
        Array(sc.nextInt()) {
            1 shl (sc.nextInt() - 1)
        }.reduce { acc, i -> acc or i }
    }
    val P = Array(M) {
        sc.nextInt()
    }

    var result = 0
    for (switch in 0 until (pow(2, N)).toInt()) {
        var num = 0
        for (i in 0 until S.count()) {
            if ((bits(S[i] and switch) % 2) == P[i]) {
                num++
            }
        }
        if (num == M) {
            result++
        }
    }

    println(result)
}
