#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int W, H, N, cnt = 0;
  int ans[100][100] = {0};
  int x[100] = {0}, y[100] = {0}, a[100] = {0};
  cin >> W >> H >> N;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans[i][j] = 1;
    }
  }
  for (int k = 0; k < N; k++) {
    cin >> x[k] >> y[k] >> a[k];
    switch (a[k]) {
      case 1:
        for (int i = 0; i < H; i++) {
          for (int j = 0; j < x[k]; j++) {
            ans[i][j] = 0;
          }
        }
        break;
      case 2:
        for (int i = 0; i < H; i++) {
          for (int j = x[k]; j < W; j++) {
            ans[i][j] = 0;
          }
        }
        break;
      case 3:
        for (int i = 0; i < y[k]; i++) {
          for (int j = 0; j < W; j++) {
            ans[i][j] = 0;
          }
        }
        break;
      case 4:
        for (int i = y[k]; i < H; i++) {
          for (int j = 0; j < W; j++) {
            ans[i][j] = 0;
          }
        }
        break;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ans[i][j] == 1) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
