object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datW, datH, datN) = readLine.split(" ").map(_.toInt)
    val data = for(i <- 1 to datN) yield (readLine.split(" ").map(_.toInt) match {case Array(a, b, c) => (a, b, c)})
    val rule1 = data.filter(_._3 == 1); val rule1OfX = if (rule1.isEmpty) 0    else rule1.map(_._1).max
    val rule2 = data.filter(_._3 == 2); val rule2OfX = if (rule2.isEmpty) datW else rule2.map(_._1).min
    val rule3 = data.filter(_._3 == 3); val rule3OfY = if (rule3.isEmpty) 0    else rule3.map(_._2).max
    val rule4 = data.filter(_._3 == 4); val rule4OfY = if (rule4.isEmpty) datH else rule4.map(_._2).min
    val ans =
      if((rule2OfX > rule1OfX) && (rule4OfY > rule3OfY)) (rule2OfX - rule1OfX) * (rule4OfY - rule3OfY)
      else 0

    println(ans)
  }
}
