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


int main(){
    int W, H, n, w = 0, h = 0;
    cin >> W >> H >> n;

    while(n--){
        int x, y, a;
        cin >> x >> y >> a;
        
        if(a == 1) w = max(w, x);
        if(a == 2) W = min(W, x);
        if(a == 3) h = max(h, y);
        if(a == 4) H = min(H, y);
    }
    cout << (w < W && h < H ? (W - w) * (H - h) : 0) << endl;
}