#include<cstdio>
int max(int a,int b) {return a>b?a:b;}
int min(int a,int b) {return a<b?a:b;}
int main()
{
	int x1=0,x2,y1=0,y2,n;
	scanf("%d%d%d",&x2,&y2,&n);
	while(n--)
	{
		int x,y,a;
		scanf("%d%d%d",&x,&y,&a);
		switch(a)
		{
			case 1:x1=max(x,x1);break;
			case 2:x2=min(x,x2);break;
			case 3:y1=max(y,y1);break;
			case 4:y2=min(y,y2);break;
		}
	}
	int ans;
	if(x1>=x2||y1>=y2) ans=0;
	else ans=(x2-x1)*(y2-y1);
	printf("%d\n",ans);
	return 0;
}