#include<stdio.h>

int main(){
  int W,H,N;

  
    scanf("%d",&W);
    scanf("%d",&H);
    scanf("%d",&N);

    int x1=0,x2=W,y1=0,y2=H;
    
    int x[N],y[N],a[N];
    
    for(int i=0;i<N;i++){
  scanf("%d",&x[i]);
  scanf("%d",&y[i]);
  scanf("%d",&a[i]);
  if(a[i]==1){
    if(x1<x[i])x1=x[i];
    }
    else if(a[i]==2){
       if(x2>x[i])x2=x[i];
    }
      else if(a[i]==3){
	 if(y1<y[i])y1=y[i];
      }
	else if(a[i]==4){
	   if(y2<y[i])y2=y[i];
	}
    }
    if(x1>x2+1)pritnf("0\n");
    else{
      printf("%d\n",(x2-x1+2)*(y2-y1+2));
    }
 
  return 0;
}
