w,h,n=list(map(int,input().split()))

x=[]

y=[]

a=[]

ax=0

ix=w

ay=0

iy=h



for i in range(n):

    x1,y1,a1=list(map(int,input().split()))

    x.append(x1)

    y.append(y1)

    a.append(a1)



for j in range(n):

    if(a[j]==1):

        ax=max(ax,x[j])

    elif(a[j]==2):

        ix=min(ix,x[j])

    elif(a[j]==3):

        ay=max(ay,y[j])

    else:

        iy=min(iy,y[j])



if(ax>=ix or ay>=iy):

    print('0')

    exit()



else:

    print(((ix-ax)*(iy-ay)))
w,h,n=list(map(int,input().split()))

ax=0

ix=w

ay=0

iy=h



for i in range(n):

    x,y,a=list(map(int,input().split()))

    if(a==1):

        ax=max(ax,x)

    elif(a==2):

        ix=min(ix,x)

    elif(a==3):

        ay=max(ay,y)

    else:

        iy=min(iy,y)



if(ax>=ix or ay>=iy):

    print('0')

    exit()



else:

    print(((ix-ax)*(iy-ay)))
w, h, n = list(map(int, input().split()))
x = []
y = []
a = []
ax = 0
ix = w
ay = 0
iy = h
for i in range(n):
    x1, y1, a1 = list(map(int, input().split()))
    x.append(x1)
    y.append(y1)
    a.append(a1)
for j in range(n):
    if a[j] == 1:
        ax = max(ax, x[j])
    elif a[j] == 2:
        ix = min(ix, x[j])
    elif a[j] == 3:
        ay = max(ay, y[j])
    else:
        iy = min(iy, y[j])
if ax >= ix or ay >= iy:
    print("0")
    exit()
else:
    print(((ix - ax) * (iy - ay)))

w, h, n = list(map(int, input().split()))
ax = 0
ix = w
ay = 0
iy = h
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        ax = max(ax, x)
    elif a == 2:
        ix = min(ix, x)
    elif a == 3:
        ay = max(ay, y)
    else:
        iy = min(iy, y)
if ax >= ix or ay >= iy:
    print("0")
    exit()
else:
    print(((ix - ax) * (iy - ay)))

-x = [] -y = [] -a = [] -    x1, y1, a1 = list(map(int, input().split())) -    x.append(x1) -    y.append(y1) -    a.append(a1) -for j in range(n): -    if a[j] == 1: -        ax = max(ax, x[j]) -    elif a[j] == 2: -        ix = min(ix, x[j]) -    elif a[j] == 3: -        ay = max(ay, y[j]) +    x, y, a = list(map(int, input().split())) +    if a == 1: +        ax = max(ax, x) +    elif a == 2: +        ix = min(ix, x) +    elif a == 3: +        ay = max(ay, y) -        iy = min(iy, y[j]) +        iy = min(iy, y)