// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

  int x1,y1,x2,y2,n,a,b,c;

  x1=0,y1=0;

  cin>>x2>>y2;

  cin>>n;

  for(int i=0;i<n;i++)

  {

      cin>>a>>b>>c;

      if(c==1)

      {

         if(a>x1)

         {

             x1=a;

         }



      }

      else if(c==2)

      {

          if(a<x2)

          {

              x2=a;

          }

      }

      else if(c==3)

      {

          if(b>y1)

          {

              y1=b;

          }

      }

      else if(c==4)

      {

          if(b<y2)

          {

              y2=b;

          }

      }

  }

  int p=x2-x1;

  int q=y2-y1;

  //cout<<p<<" "<<q<<endl;

  if(p<=0 || q<=0)cout<<0;

  else  cout<<p*q;

}










// Faster C++ solution for the same problem (measured speedup: 6.388867121818888x):
/**

DufauX-XuafuD

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<long long, long long> pll;

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define all(x) (x).begin(), (x).end()

#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define reset(x) memset(x,-1,sizeof(x))

#define CheckBit(a,b) (a&(1ll<<b))

#define SetBit(a,b) a=(a|(1ll<<b))

#define UnSetBit(a,b) a=(a&(~(1ll<<b)))

#define maxx 10000006

#define PI 2*acos(0.0)

const long long INF = 2000000000000000000LL;	// 2e18

const int inf = 0x3f3f3f3f;	// 1061109567

const long double EPS = 1e-9;

//bitset<maxx/2>vis;

//bitset<maxx>pr;

//int mobi[maxx+10];

//vector<ll>prime;

//void sieve(){

//    ll x=maxx/2, y=sqrt(maxx)/2;

//    for(ll i=1;i<=y;i++){

//        if(vis[i]==0){

//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)

//                vis[j]=1;

//        }

//    }

//    prime.push_back(2);

//    for(ll i=3;i<maxx;i+=2)

//        if(vis[i/2]==0)

//        prime.push_back(i);

//}

//void generate_mobius()

//{

//    for(int i=0;i<maxx;i++)mobi[i]=1;

//    for(int i=2;i<maxx;i++){

//        if(!pr[i]){

//            mobi[i]*=-1;

//            for(int j=i+i;j<maxx;j+=i){

//                pr[j]=1;

//                mobi[j]*=(j%(i*i)?-1:0);

//            }

//        }

//    }

//}

//bool isprime(ll a)

//{

//    if(a==1)return false;

//    if(a==2)return true;

//    if(a%2==0)return false;

//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)

//        if(a%prime[i]==0)return false;

//    return true;

//}

/* Calculate ( a*b ) %c */

inline ll mulmod(ll a, ll b, ll c) {

    ll ret = 0 , cur = a % c ;

    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }

    return ret%c;

}

//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)

inline ll bigmod(ll b, ll p, ll m){

    ll ret = 1, cur = b % m;

    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }

    return ret;

}

inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10

    ll ret = 1 , cur = a%c ;

    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }

    return ret%c ;

}

inline ll power(ll b, ll p){

    ll ret = 1, cur = b;

    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }

    return ret;

}

ll lcm(ll a,ll b)

{

    return (a/__gcd(a,b))*b;

}

ll gcd(ll a,ll b)

{

    return __gcd(a,b);

}

ll matrix[200][200];

void Dufaux()

{

    ll w,h,n;

    cin>>w>>h>>n;

    for(int i=1;i<=n;i++){

        ll x,y,a;

        cin>>x>>y>>a;

        if(a==1){

            for(int i=0;i<=x;i++){

                for(int j=0;j<=h;j++){

                    matrix[i][j]=1;

                }

            }

        }

        else if(a==2){

            for(int i=x+1;i<=w;i++){

                for(int j=0;j<=h;j++){

                    matrix[i][j]=1;

                }

            }

        }

        else if(a==3){

            for(int i=0;i<=w;i++){

                for(int j=0;j<=y;j++){

                    matrix[i][j]=1;

                }

            }

        }

        else{

            for(int i=0;i<=w;i++){

                for(int j=y+1;j<=h;j++){

                    matrix[i][j]=1;

                }

            }

        }

    }

    ll cnt=0;

    for(int i=1;i<=w;i++){

        for(int j=1;j<=h;j++){

            if(matrix[i][j]==0)cnt++;

        }

    }

    cout<<cnt<<endl;

}

int main()

{

    FastIO;

	///sieve();

	///generate_mobius();

	int test=1;

	while(test--){

        Dufaux();

	}

	return 0;

}