#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, sx = 0, sy = 0, ex, ey, chk;
  int W, H, N;
  cin >> W >> H >> N;
  ex = W, ey = H;
  for (int i = 0; i < N; i++) {
    cin >> x >> y >> chk;
    switch (chk) {
      case 1:
        if (x >= sx) sx = x;
        break;
      case 2:
        if (x <= ex) ex = x;
        break;
      case 3:
        if (y >= sy) sy = y;
        break;
      case 4:
        if (y <= ey) ey = y;
        break;
    }
  }
  int result = (ex - sx) * (ey - sy) <= 0 ? 0 : (ex - sx) * (ey - sy);
  cout << result << endl;
}
