#include <bits/stdc++.h>
using namespace std;
int w, h, n, x[100], y[100], a[100];
int x1, Y1;
int b, c, d, f, g;
int main() {
  cin >> w >> h >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> a[i];
  }
  x1 = 0;
  Y1 = 0;
  for (int i = 0; i < n; i++) {
    b = a[i];
    c = y[i];
    d = x[i];
    if (b == 1 && d < w) {
      w = d;
    } else if (b == 2 && d > x1 && d < w) {
      x1 = d;
    } else if (b == 3 && c < h) {
      h = c;
    } else if (b == 4 && Y1 < c && c < h) {
      Y1 = c;
    } else if (b == 1 && d >= w) {
      if (i > 0) {
        w = x[i - 1];
        w = g;
      } else {
        f = w;
        w = f;
      }
    } else if (b == 3 && c >= h) {
      if (i > 0) {
        h = y[i - 1];
      } else {
        g = w;
        w = g;
      }
    } else {
      cout << 0 << endl;
      return 0;
    }
  }
  if ((w - x1) > 0 && (h - Y1) > 0) {
    cout << (w - x1) * (h - Y1) << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
