import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long w, h, n;
    scan(w, h, n);
    auto square = new long[][](h, w);
    foreach (i; iota(n))
    {
        long x, y, a;
        scan(x, y, a);
        switch (a)
        {
        case 1:
            draw(square, 0, x, 0, h);
            break;
        case 2:
            draw(square, x, w, 0, h);
            break;
        case 3:
            draw(square, 0, w, 0, y);
            break;
        case 4:
            draw(square, 0, w, y, h);
            break;
        default:
            assert(0);
        }
    }
    long cnt;
    foreach (i; iota(h))
    {
        foreach (j; iota(w))
        {
            if (square[i][j] == 0)
                cnt++;
        }
    }
    cnt.writeln();
}

void draw(T)(ref T wall, long right, long left, long lower, long upper)
{
    foreach (i; iota(lower, upper))
    {
        foreach (j; iota(right, left))
        {
            wall[i][j]++;
        }
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
