object Main {

  import Math.pow

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val M = sc.nextInt
    val k = new Array[Int](M)
    val s = new Array[Long](M)
    for (i <- 0 until M) {
      k(i) = sc.nextInt
      var tmp = 0L
      for (j <- 0 until k(i)) {
        tmp += pow(10.0, sc.nextInt - 1).toLong
      }
      s(i) = tmp
    }

    val p = Array.fill(M)(sc.nextInt)
    var result = 0

    def countOn(b: Int): Unit = {
      for (i <- 0 until M) {
        val on = b & s(i)
        if (on.toBinaryString.count(_.==('1')) % 2 != p(i)) {
          return
        }
      }
      result += 1
    }

    for (b <- 0 until pow(2.0, N).toInt) {
      countOn(b)
    }
    println(result)
  }
}
