#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int w,h,n,x,y,a,i;cin >> w >> h >> n;
  int xmin = 0,xmax = w,ymin = 0,ymax = h;
  for(i=0;i<n;i++){
    cin >> x >> y >> a;
    if(a==1) xmin = max(xmin,x);
    else if(a==2) xmax = min(xmax,x);
    else if(a==3) ymin = max(ymin,y);
    else ymax = min(ymax,y);
  }
  if(xmin >= xmax || ymin >= ymax) cout << 0 << endl;
  else cout << (xmax-xmin)*(ymax-ymin) << endl;
}