#!/bin/bash
read w h n

minx=0
maxx=$w
miny=0
maxy=$h
n=$(echo $n | sed "s/\n//")
for i in $(seq 1 $n); do
  read x y a
  a=$(echo $a | sed "s/\n//")
  if [ $a -eq 1 ]; then
    if [ $x -gt $minx ]; then
      minx=$x
    fi
  elif [ $a -eq 2 ]; then
    if [ $x -lt $maxx ]; then
      maxx=$x
    fi
  elif [ $a -eq 3 ]; then
    if [ $y -gt $miny ]; then
      miny=$y
    fi
  elif [ $a -eq 4 ]; then
    if [ $y -lt $maxy ]; then
      maxy=$y
    fi
  fi
done

ans=$(((maxx-minx)*(maxy-miny)))

[ $ans -lt 0 ] && ans=0
echo $ans
