fun main() {
  val (N, M) = readInts()
  val S = (1..M).map { readInts().drop(1) }
  val P = readInts()

  fun isAllLighting(b: Int): Boolean {
    S.forEachIndexed { i, s ->
      val p = P[i]
      var cnt = 0
      s.forEach { si ->
        val mask = 1.shl(si - 1)
        if (mask.and(b) > 0) cnt++
      }
      if (cnt % 2 != p) return false
    }
    return true
  }

  var cnt = 0
  for (b in 0 until 1.shl(N)) {
    if (isAllLighting(b)) cnt++
  }
  println(cnt)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
