#include <bits/stdc++.h>
using namespace std;
int main(){
	int w,h,n;
	cin>>w>>h>>n;
	int x1=0,y1=0,x2=w,y2=h;
	for(int i=0;i<n;i++){
		int p,q,r;
		cin>>p>>q>>r;
		if(r==1&&x1<p) x1=p;
		else if(r==2&&x2>p) x2=p;
		else if(r==3&&y1<q) y1=q;
		else if(r==4&&y2>q) y2=q;
	}
	w=x2-x1;
	h=y2-y1;
	if(w<=0||h<=0)cout<<0<<endl;
	else cout<<w*h<<endl;
	return 0;
}