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

int main() {
  int X, Y, N;
  cin >> X >> Y >> N;
  int xl = 0, xr = X;
  int yl = 0, yr = Y;
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) xl = max(x,xl);
    if (a == 2) xr = min(x,xr);
    if (a == 3) yl = max(y,yl);
    if (a == 4) yr = min(y,yr);
  }
  cout << max(0,xr-xl) * max(0,yr-yl) << endl;
}