import kotlin.comparisons.*
import java.util.*

const val MOD = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (n, m) = readIs()
  val ss = IntArray(m)
  repeat(m) {
    val ks = readIs()
    var s = 0
    for (i in 1..ks[0]) {
      s += 1 shl (ks[i] - 1)
    }
    ss[it] = s
  }
  val pp = readIs()
  var ans = 0
  next@for (i in 0 until (1 shl n)) {
    for (j in 0 until m) {
      val x = Integer.bitCount(i and ss[j])
      if (x % 2 != pp[j]) continue@next
    }
    ans++
  }
  println(ans)
}
