void main() {
    int[] tmp = readln.split.to!(int[]);
    int w = tmp[0], h = tmp[1], n = tmp[2];
    int[] x = new int[n], y = new int[n], a = new int[n];
    foreach (i; 0 .. n) {
        tmp = readln.split.to!(int[]);
        x[i] = tmp[0], y[i] = tmp[1], a[i] = tmp[2];
    }
    int xmin, xmax = w, ymin, ymax = h;
    foreach (i; 0 .. n) {
        if (a[i] == 1) {
            xmin = max(xmin, x[i]);
        } else if (a[i] == 2) {
            xmax = min(xmax, x[i]);
        } else if (a[i] == 3) {
            ymin = max(ymin, y[i]);
        } else {
            ymax = min(ymax, y[i]);
        }
    }
    writeln(max(0, xmax-xmin) * max(0, ymax-ymin));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;