#include <bits/stdc++.h>
using namespace std;
int main(){
	int w,h,n,x[1000],y[1000],e[1000];
	cin>>w>>h>>n;
	int a=0,b=w,c=0,d=h;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>e[i];
		if(e[i]==1)a=max(a,x[i]);
        if(e[i]==2)b=min(b,x[i]);
        if(e[i]==3)c=max(c,y[i]);
        if(e[i]==4)d=min(d,y[i]);
	}
	cout<<max(0,b-a)*max(0,d-c)<<endl;
}
