function Main(input) {
  input = input.split("\n");
  tmp = input[0].split(" ");
  var wmax = parseInt(tmp[0]);
  var hmax = parseInt(tmp[1]);
  var n = parseInt(tmp[2]);
  var wmin =0;
  var hmin =0;
  x=new Array(n).fill(0);
  y=new Array(n).fill(0);
  a=new Array(n).fill(0);
  var ans=0;
  for(i=0;i<n;i++){
    x[i]=parseInt(input[i+1].split(" ")[0]);
    y[i]=parseInt(input[i+1].split(" ")[1]);
    a[i]=parseInt(input[i+1].split(" ")[2]);
  }
  for(i=0;i<n;i++){
    if(a[i]==1&&x[i]>wmin){
      wmin=x[i];
    }else if(a[i]==2&&x[i]<wmax){
      wmax=x[i];
    }else if(a[i]==3&&y[i]>hmin){
      hmin=y[i];
    }else if(a[i]==4&&y[i]<hmax){
      hmax=y[i];
    }
  }
  if(hmax<hmin||wmax<wmin){
    ans=0;
  }else{
    ans=(hmax-hmin)*(wmax-wmin);
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));