program main
  implicit none
  
  integer :: h,w,n,xmin=200,xmax=0,ymin=200,ymax=0,i,x,y,a
  
  read(*,*)w,h,n
  do i = 1, n
    read(*,*)x,y,a
    if (a == 1) then
      if (x < xmin) then
        xmin = x
      end if
    else if (a == 2) then
      if (x > xmax) then
        xmax = x
      end if
    else if (a == 3) then
      if (y < ymin) then
        ymin = y
      end if
    else if (a == 4) then
      if (y > ymax) then
        ymax = y
      end if
    end if
  end do
  
  if ((xmin > xmax) .or. (ymin > ymax)) then
    write(*,*)0
  else
    write(*,*)(xmax - xmin)*(ymax - ymin)
  end if
end program main