#include <bits/stdc++.h>
using namespace std;

int main() {
  int W, H, N, X, Y, A;
  cin >> W >> H >> N;

  int B = 0, C = 0, D = 0, E = 0;

  for (int i = 0; i < N; i++) {
    cin >> X >> Y >> A;
    if (A == 1) B = max(B, X);
    else if (A == 2) C = max(C, W - X);
    else if (A == 3) D = max(D, Y);
    else E = max(E, H - Y);
  }

  cout << ((B + C < W && D + E < H) ? (W - B - C) * (H - D - E) : 0) << endl;
}