#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, n;
  int w0 = 0, h0 = 0;
  cin >> w >> h >> n;
  vector<vector<int> > xy(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) cin >> xy[i][j];
  }
  for (int i = 0; i < n; i++) {
    if (xy[i][2] == 1 & w0 < xy[i][0]) w0 = xy[i][0];
    if (xy[i][2] == 2 & w > xy[i][0]) w = xy[i][0];
    if (xy[i][2] == 3 & h0 < xy[i][1]) h0 = xy[i][1];
    if (xy[i][2] == 4 & h > xy[i][1]) h = xy[i][1];
  }
  if ((w - w0) | (h - h0))
    cout << 0 << endl;
  else
    cout << (w - w0) * (h - h0) << endl;
}
