import java.util.Scanner

import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.annotation.tailrec
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  case class Light(num: Int, switches: Seq[Int], condition: Int)

  def solve(sc: Scanner): String = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    val bulbs = (0 until m).map { i =>
      val k = sc.nextInt()
      val switches = IndexedSeq.fill(k)(sc.nextInt() - 1)
      (k, switches)
    }
    val conditions = IndexedSeq.fill(m)(sc.nextInt())
    val lights = (0 until m).foldLeft(ArrayBuffer.empty[Light]) { (acc, i) =>
      val (_, switches) = bulbs(i)
      val condition = conditions(i)
      acc += Light(i + 1, switches, condition)
      acc
    }.toIndexedSeq
    debug(n, m, lights)

    var count = 0
    patterns(n).foreach { p =>
      val lightOnCounts = lights.foldLeft(0) { (acc, light) =>
        if (p.zipWithIndex.filter { case (_, i) => light.switches.contains(i) }.map(_._1).sum % 2 == light.condition) {
          acc + 1
        } else {
          acc
        }
      }
      if (lightOnCounts == lights.size) count += 1
    }
    count.toString
  }

  def patterns(n: Int): IndexedSeq[ArrayBuffer[Int]] = {
    val patternBufList = IndexedSeq.fill(pow(2, n).toInt)(ArrayBuffer.empty[Int])

    @tailrec
    def dfs(patternBufList: IndexedSeq[ArrayBuffer[Int]], n: Int): IndexedSeq[ArrayBuffer[Int]] = {
      if (n > 0) {
        patternBufList.zipWithIndex.foreach { case (a, i) =>
          a += floor(i / (pow(2, n) / 2) % 2).toInt
        }
        dfs(patternBufList, n - 1)
      } else patternBufList
    }

    dfs(patternBufList, n)
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}
