#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,w,h,n,x,y,a,left,right,up,down; 
	cin>>w>>h>>n;
	left=0;right=w;right=0;up=h;i<=n;i++;
	{
		cin>>x>>y>>a;
	for(int i=1)
		if(a==1)left=max(left,x);
		if(a==2)right=min(right,x);
		if(a==3)down=max(down,y);
		if(a==4)up=min(up,y);
	}
	if(left>right||down>up)cout<<0;
	else
	    cout<<(right-left)*(up-down);
	return 0;
}