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

int main(){
  int w,h,n;
  cin >> w>> h >> n;
  int left=0,right=w,bottom=0,top=h;
  for(int i=0; i<n; i++){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1)left=max(left,x);
    if(a==2)right=min(right,x);
    if(a==3)bottom=max(bottom,y);
    if(a==4)top=min(top,y);
  }
  int ans = 0;
  cout << max(0,right-left)*max(0,top-bottom) << endl;
}