import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int w, h, n; readV(w, h, n);

  auto x1 = 0, x2 = w, y1 = 0, y2 = h;
  foreach (_; 0..n) {
    int x, y, a; readV(x, y, a);
    switch (a) {
    case 1: x1 = max(x1, x); break;
    case 2: x2 = min(x2, x); break;
    case 3: y1 = max(y1, y); break;
    case 4: y2 = min(y2, y); break;
    default: assert(0);
    }
  }

  writeln(x2<x1 || y2<y1 ? 0 : (x2-x1)*(y2-y1));
}
