<?php
list($W, $H, $N) = explode(' ', trim(fgets(STDIN)));
$data = [];
for ($i = 0; $i < $N; $i++) {
    $data[] = explode(' ', trim(fgets(STDIN)));
}

$xmin = 0;
$xmax = $W;
$ymin = 0;
$ymax = $H;

foreach ($data as $d) {
    $x = $d[0];
    $y = $d[1];
    $a = $d[2];

    switch($a) {
    case 1:
        $xmin = max($x, $xmin);
        break;
    case 2:
        $xmax = min($x, $xmax);
        break;
    case 3:
        $ymin = max($y, $ymin);
        break;
    case 4:
        $ymax = min($y, $ymax);
        break;
    }
}

$w = max($xmax - $xmin, 0);
$h = max($ymax - $ymin, 0);

$s = (int)($w * $h);

echo "$s\n";