#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
istream& operator>>(istream& is, pair<S, T>& p) {
  return is >> p.first >> p.second;
}
void chmin(int& x, int y) {
  if (x > y) x = y;
}
void chmax(int& x, int y) {
  if (x < y) x = y;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const long long MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N;
  pair<int, int> x, y;
  cin >> x.second >> y.second >> N;
  for (int i = (0); i < (N); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    switch (c) {
      case 1:
        chmax(x.first, a);
        break;
      case 2:
        chmin(x.second, a);
        break;
      case 3:
        chmax(y.first, b);
        break;
      case 4:
        chmin(y.second, b);
        break;
    }
  }
  cout << max(0, x.second - x.first) * max(0, y.second - y.first) << endl;
  return 0;
}
