import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
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 LightBulb(switches: Seq[Int], condition: Int)

  def solve(sc: Scanner): String = {
    val (n, m, lightbulbs) = parseInput(sc)
    debug(n, m, lightbulbs)

    var countOfAllOn = 0
    getSwitchPatterns(n).foreach { sp =>
      val countOfOn = lightbulbs.foldLeft(0) { (acc, lightbulb) =>
        if (sp.zipWithIndex.filter { case (_, i) => lightbulb.switches.contains(i) }.map(_._1).sum % 2 == lightbulb.condition) {
          acc + 1
        } else {
          acc
        }
      }
      if (countOfOn == lightbulbs.size) countOfAllOn += 1
    }
    countOfAllOn.toString
  }

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

    val initialList = (0 until pow(2, n).toInt).map(i => (ArrayBuffer.empty[Int], i)).toVector
    dfs(initialList, n).map(_._1)
  }

  def parseInput(sc: Scanner) = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    val switchesList = (0 until m).map { _ =>
      val k = sc.nextInt()
      Vector.fill(k)(sc.nextInt() - 1)
    }
    val conditionList = Vector.fill(m)(sc.nextInt())
    val lightbulbs = (0 until m).foldLeft(ArrayBuffer.empty[LightBulb]) { (acc, i) =>
      acc += LightBulb(switchesList(i), conditionList(i))
      acc
    }.toVector
    (n, m, lightbulbs)
  }

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