using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
//        int d = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int x0 = 0;
        int y0 = 0;
        for(int i=0;i<c;i++){
            string[] temp = ReadLine().Split(' ');
            int n = int.Parse(temp[0]);
            int m = int.Parse(temp[1]);
            int k = int.Parse(temp[2]);
            if(k==1){    x0 = Max(x0,n);    }
            if(k==2){    a = Min(a,n);    }
            if(k==3){    y0 = Max(y0,m);    }
            if(k==4){    b = Min(b,m);    }
        }
        if(a-x0 >= 0 && b-y0 >= 0){
            WriteLine((a-x0)*(b-y0));
        }else{
            WriteLine("0");
        }
    }
}