#include<bits/stdc++.h>
using namespace std;

int main() 
{
    int w,h,n,x,y,a,left,right,up,down;
    cin>>w>>h>>n;
    left=0;right=w;down=0;up=h;
    for(int i=1;i<=n;i++)
    {
    	cin>>x>>y>>a;
    	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; 
}
