import scala.io.StdIn

object Main extends App {

  case class Point(index: Int, x: Int, y: Int, pattern: Int)

  case class Rect(xs: Int, xe: Int, ys: Int, ye: Int)

  val Array(w, h, n) = StdIn.readLine().split(" ").map(_.toInt)
  val points = (0 until n).map { i =>
    val a = StdIn.readLine().split(" ").map(_.toInt)
    Point(i, a(0), a(1), a(2))
  }

  val r = points.foldLeft(Rect(0, w, 0, h)) { (acc, p) =>
    p.pattern match {
      case 1 => Rect(if (acc.xs < p.x) p.x else acc.xs, acc.xe, acc.ys, acc.ye) // < Xi
      case 2 => Rect(acc.xs, if (acc.xe > p.x) p.x else acc.xe, acc.ys, acc.ye) // > Xi
      case 3 => Rect(acc.xs, acc.xe, if (acc.ys < p.y) p.y else acc.ys , acc.ye) // < Yi
      case 4 => Rect(acc.xs, acc.xe, acc.ys, if (acc.ye > p.y) p.y else acc.ye) // > Yi
    }
  }
  // println(r)
  // println(r.xe - r.xs , r.ye - r.ys)
  val e = (r.xe - r.xs) * (r.ye - r.ys)
  println(if(e < 0) 0 else e)
}
