import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val Array(w, h, n) = StdIn.readLine().trim.split(' ').map(_.toInt)

    val (xs, ys, as) = (1 to n).map { _ =>
      val Array(x, y, a) = StdIn.readLine().trim.split(' ').map(_.toInt)
      (x, y, a)
    }.unzip3

    var (left, right, top, bottom) = (0, w, h, 0)

    (0 until n).foreach { i =>

      as(i) match {
        case 1 =>
          if (left < xs(i)) { left = xs(i) }
        case 2 =>
          if (xs(i) < right) { right = xs(i) }
        case 3 =>
          if (bottom < ys(i)) { bottom = ys(i) }
        case 4 =>
          if (ys(i) < top) { top = ys(i) }
      }
    }

    if (left < right && bottom < top) {
      println((right - left) * (top - bottom))
    } else {
      println(0)
    }
  }
}
