fun main(args: Array<String>) {
    val firstLine = readLine()?.split(" ").orEmpty()
    val widthWhole = firstLine[0].toInt()
    val heightWhole = firstLine[1].toInt()
    val quantPoints = firstLine[2].toInt()
    var blankArea = 0
    var leftDraw = 0
    var rightDraw = widthWhole
    var topDraw = heightWhole
    var bottomDraw = 0

    for(i in 0 until quantPoints){
        val grid = readLine()?.split(" ").orEmpty()
        val gridX = grid[0].toInt()
        val gridY = grid[1].toInt()

        when (grid[2].toInt()) {
            1 -> {
                if(gridX > leftDraw){
                    leftDraw = gridX
                }
            }
            2 -> {
                if(gridX < rightDraw) {
                    rightDraw = gridX
                }
            }
            3-> {
                if(gridY > bottomDraw){
                    bottomDraw = gridY
                }
            }
            4 -> {
                if(gridY < topDraw) {
                    topDraw = gridY
                }
            }
        }

    }

    val blankWidth = rightDraw - leftDraw
    val blankHeight = topDraw - bottomDraw


    if(blankWidth > 0 && blankHeight > 0){
        blankArea = blankWidth * blankHeight
    }

    println(blankArea)
}