#include <bits/stdc++.h>
using namespace std;
int main() {
  int xmax, ymax, n;
  cin >> xmax >> ymax >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);
  int xmin = 0;
  int ymin = 0;
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
    if (a.at(i) == 1) {
      xmin = max(xmin, x.at(i));
    } else if (a.at(i) == 2) {
      xmax = min(xmax, x.at(i));
    } else if (a.at(i) == 3) {
      ymin = max(ymin, y.at(i));
    } else if (a.at(i) == 4) {
      ymax = min(ymax, y.at(i));
    }
  }
  int s;
  s = max(0, (xmax - xmin)) * max(0, (ymax - ymin));
  cout << s << endl;
}
