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