import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))

    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val bulbsSwitchesWithCriteria = Array.fill(m) {
      in.readLine().split("\\s+").map(_.toInt - 1).tail
    }.zip {
      in.readLine().split("\\s+").map(_.toInt)
    }

    out.println(
      (0 until Math.pow(2, n).toInt).count { switchStatus =>
        bulbsSwitchesWithCriteria forall {
          case (bulbSwitches, criterion) =>
            bulbSwitches.count { bulbSwitch =>
              (switchStatus >> bulbSwitch & 1) == 1
            } % 2 == criterion
        }
      }
    )
    out.flush()
  }
}
