import java.util.*
import java.math.*

fun main(args: Array<String>) {

    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val mod = 1000000007L
    val K = mutableListOf<IntArray>()
    for (n in 1..M) {
        val k = readLine()!!.split(" ").drop(1).map { it.toInt() }.toIntArray()
        K.add(k)
    }
    val p = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var ans = 0
    val list = BooleanArray(N) { false }

    fun o(n: Int): Int {
        if (n < N){
            var res = 0
            list[n] = false
            res += o(n + 1)
            list[n] = true
            res += o(n + 1)
            return res
        }
//        println(list.toList())

        for ((i, k) in K.withIndex()) {
            var on = 0
            for (n in k) {
                if (list[n - 1]) on++
            }
            if (on % 2 != p[i]) {
                return 0
            }
        }

        return 1
    }

    println(o(0))

//    println("%.9f".format(ans))
}
