#include <bits/stdc++.h>
using namespace std;
int main() {
  int W, H, N, p, q, r, s;
  cin >> W >> H >> N;
  vector<vector<int>> A(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  p = 0, q = W, r = 0, s = H;
  for (int i = 0; i < N; i++) {
    if (A.at(i).at(2) == 1) p = max(p, A.at(i).at(0));
    if (A.at(i).at(2) == 2) q = min(q, A.at(i).at(0));
    if (A.at(i).at(2) == 3) r = max(r, A.at(i).at(1));
    if (A.at(i).at(2) == 4) s = min(s, A.at(i).at(1));
  }
  if (q >= p && s >= r)
    cout << (q - p) * (s - r) << endl;
  else
    cout << 0 << endl;
}
