program main
implicit none
integer :: i, j, k
integer :: w, h, n, p, q, r, s
integer , allocatable :: a(:), x(:), y(:)

read(*,*) w, h, n
allocate( a(n), x(n), y(n) )
p = 0
q = w
r = 0
s = h
do i = 1, n
   read(*,*) x(i), y(i), a(i)
   if( a(i) == 1 .and. x(i).ge.p ) then
      p = x(i)
   end if
   if( a(i) == 2 .and. x(i).le.q ) then
      q = x(i)
   end if
   if( a(i) == 3 .and. y(i).ge.r ) then
      r = y(i)
   end if
   if( a(i) == 4 .and. y(i).le.s ) then
      s = y(i)
   end if
end do
if( p.ge. q .or. r.ge.s ) then 
   write(*,'(i0)') 0
else
   write(*,'(i0)') (q-p)*(s-r)
end if


end program main
