import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main()
{
	auto param = readln.chomp.split(' ').map!(to!long).array;
    long W = param[0];
    long H = param[1];
    long N = param[2];
    long left = 0;
    long right = W;
    long top = H;
    long bottom = 0;
    foreach(i;0 .. N)
    {
        auto cmd = readln.chomp.split(' ').map!(to!long).array;
        switch(cmd[2])
        {
            case 1:
                left = max(cmd[0],left);
                break;
            case 2:
                right = min(cmd[0],right);
                break;
            case 3:
                bottom = max(cmd[1],bottom);
                break;
            case 4:
                top = min(cmd[1],top);
                break;
            default:
                assert(0);
        }
    }
    bool isZero = (right < left) || (top < bottom);
    if (isZero)
    {
        writeln(0);
        return;
    }
    long S = (right - left) * (top - bottom);
    writeln(S);
}