#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int A[3 * n];
  for (int i = 0; i < 3 * n; i++) {
    cin >> A[i];
  }
  int C[w][h];
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      C[i][j] == 0;
    }
  }
  for (int k = 0; k < n; k++) {
    if (A[3 * k + 2] == 1) {
      for (int j = 0; j < h; j++) {
        for (int i = A[3 * k] - 1; i >= 0; i--) {
          C[i][j] = 1;
        }
      }
    } else if (A[3 * k + 2] == 2) {
      for (int j = 0; j < h; j++) {
        for (int i = A[3 * k]; i <= w - 1; i++) {
          C[i][j] = 1;
        }
      }
    } else if (A[3 * k + 2] == 3) {
      for (int i = 0; i < w; i++) {
        for (int j = A[3 * k + 1] - 1; j >= 0; j--) {
          C[i][j] = 1;
        }
      }
    } else if (A[3 * k + 2] == 4) {
      for (int i = 0; i < w; i++) {
        for (int j = A[3 * k + 1]; j <= h - 1; j++) {
          C[i][j] = 1;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (C[i][j] == 1) {
        cnt++;
      }
    }
  }
  cout << w * h - cnt << endl;
}
