'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const W = parseInt(args[0][0], 10)
	const H = parseInt(args[0][1], 10)
	const N = parseInt(args[0][2], 10)
	const t = args.slice(1, N + 1)
	const map = new Array(W)
	for (let i = 0; i < W; i++) map[i] = new Array(H).fill(false)

	for (let i = 0; i < N; i++) {
		const x = parseInt(t[i][0], 10)
		const y = parseInt(t[i][1], 10)
		const a = parseInt(t[i][2], 10)

		for (let j = 0; j < W; j++) {
			for (let k = 0; k < H; k++) {
				if (a === 1) {
					if (j < x) map[j][k] = true
				} else if (a === 2) {
					if (j >= x) map[j][k] = true
				} else if (a === 3) {
					if (k < y) map[j][k] = true
				} else {
					if (k >= y) map[j][k] = true
				}
			}
		}
	}

	let cnt = 0

	for (let i = 0; i < W; i++) {
		for (let j = 0; j < H; j++) {
			if (!map[i][j]) cnt++
		}
	}

	console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
