#include <bits/stdc++.h>
using namespace std;
bool compare_first(pair<int, int> a, pair<int, int> b) {
  return a.first < b.first;
}
bool compare_second(pair<int, pair<int, int> > a,
                    pair<int, pair<int, int> > b) {
  return a.second.first < b.second.first;
}
long long min(long long a, long long b) {
  if (a > b) return b;
  return a;
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long toINT(string s) {
  long long a = 0;
  for (long long index = 0; index < s.size(); index++)
    a = a * 10 + (s[index] - '0');
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  int w, h, n;
  cin >> w >> h >> n;
  int xmn = 0, ymn = 0, xmx = w, ymx = h;
  while (n--) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1)
      xmn = max(x, xmn);
    else if (a == 2)
      xmx = min(x, xmn);
    else if (a == 3)
      ymn = max(y, ymn);
    else if (a == 4)
      ymx = min(y, ymx);
  }
  cout << max(0, xmx - xmn) * max(0, ymx - ymn) << endl;
  return 0;
}
