#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int x, y, a;
  int b[100][100] = {};
  int minx = 100, miny = 100;
  while (1) {
    if (n == 0) break;
    cin >> x >> y >> a;
    if (a == 1)
      if (minx > w - x)
        minx = w - x;
      else if (a == 2)
        if (minx > x)
          minx = x;
        else if (a == 3)
          if (miny > h - y)
            miny = h - y;
          else if (a == 4)
            if (miny > y) miny = y;
    n--;
  }
  cout << minx * miny << endl;
  return 0;
}
