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

int main() {
	int w, h, n;
	int a, b, c;
	cin>>w>>h>>n;
	
	int x2 = w, y2 = h;
	int x1 = 0, y1 = 0;
	for(int i=0;i<n;++i) {
		cin>>a>>b>>c;
		if(c==1) x1 = max(x1, a);
		else if(c==2) x2 = min(x2, a);
		else if(c==3) y1 = max(y1, b);
		else if(c==4) y2 = min(y2, b);
	}

	int res;
	if(x1>=x2 || y1>=y2) res = 0;
	else res = (x2-x1) * (y2-y1);
	cout<<res<<endl;
	return 0;
}