#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int x, y, a;
  int left = 0, right = w, up = h, down = 0;
  int area = (up - down) * (right - left), ans = area;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y >> a;
    if (a == 1) {
      left = x;
    } else if (a == 2) {
      right = x;
    } else if (a == 3) {
      down = y;
    } else {
      up = y;
    }
    area = (up - down) * (right - left);
    if (up <= down || right <= left) area = 0;
    if (area < 0) area = 0;
    ans = min(area, ans);
  }
  cout << ans << endl;
  return 0;
}
