function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var Wmax = parseInt(input[0].split(" ")[0]);
  var Hmax = parseInt(input[0].split(" ")[1]);
  var N = parseInt(input[0].split(" ")[2]);
  var Wmin = 0;
  var Hmin = 0;
  for(var i = 1; i <= N ; i++){
    var tmp = input[i].split(" ").map((a)=>Number(a));
    switch(tmp[2]){
      case 1:
        Wmin = tmp[0];
        break;
      case 2:
        Wmax = tmp[0];
        break;
      case 3:
        Hmin = tmp[1];
        break;
      case 4:
        Hmax = tmp[1];
        break;
    }
  }
  if(Wmin > Wmax || Hmin > Hmax){
     myout("0");
  }else{
    myout((Wmax - Wmin) * (Hmax - Hmin));
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
