#include <bits/stdc++.h>
int main() {
  int W, H, N;
  int W_0 = 0;
  int H_0 = 0;
  scanf("%d", &W);
  scanf("%d", &H);
  scanf("%d", &N);
  int x[N];
  int y[N];
  int a[N];
  int sq;
  for (int i = 0; i < N; i++) {
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < N; i++) {
    if (a[i] == 1) {
      if (W_0 < x[i]) {
        W_0 = x[i];
        if (W_0 > W) {
          printf("0\n");
          return 0;
        }
      }
    } else if (a[i] == 2) {
      if (W > x[i]) {
        W = x[i];
        if (W_0 > W) {
          printf("0\n");
          return 0;
        }
      }
    } else if (a[i] == 3) {
      if (H_0 < y[i]) {
        H_0 = y[i];
        if (H_0 > H) {
          printf("0\n");
          return 0;
        }
      }
    } else if (a[i] == 4) {
      if (H > x[i]) {
        H = x[i];
        if (H_0 > H) {
          printf("0\n");
          return 0;
        }
      }
    }
  }
  sq = (W - W_0) * (H - H_0);
  printf("%d\n", sq);
  return 0;
}
