"use strict"

const { ifError } = require("assert");

const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [w,h,n] = nextIntArray()
    let xMin = 0
    let xMax = w
    let yMin = 0
    let yMax = h
    while(hasNext()){
        let tmp = nextIntArray()
        switch(tmp[2]){
            case 1:
                xMin = Math.max(xMin, tmp[0])
                break
            case 2:
                xMax = Math.min(xMax, tmp[0])
                break
            case 3:
                yMin = Math.max(yMin, tmp[1])
                break
            case 4:
                yMax = Math.min(yMax, tmp[1])
                break
        }
    }
    if(xMin >= xMax || yMin > yMax){
        console.log(0)
        return
    }
    console.log((xMax-xMin)*(yMax-yMin))

}
Main()

