#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w, h, n;
  cin >> w >> h >> n;
  int xmin = 0, xmax = w, ymin = 0, ymax = h;
  for (int i = 0; i < n; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      xmin = max(0, x);
    } else if (a == 2) {
      xmax = min(w, x);
    } else if (a == 3) {
      ymin = max(0, y);
    } else if (a == 4) {
      ymax = min(h, y);
    }
  }
  cout << max(0, xmax - xmin) * max(0, ymax - ymin) << endl;
}
