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



#座標用配列

s = [[1 for i in range(w)] for j in range(h)]



    

#標準入力

for i in range(n):

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

    if a == 1:

        for j in range(h):

            s[j][0:x] = [0 for k in range(x)]         

    elif a ==2:

        for j in range(h):

            s[j][x:w] = [0 for k in range(x,w)]       

    elif a ==3:

        for j in range(y):

            s[j] = [0 for k in range(w)]   

    elif a==4:

        for j in range(y,h):

            s[j] =[0 for k in range(w)]

            



cnt = 0

for i in s:

    cnt += sum(i)

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



x_min = 0

x_max = w

y_min = 0

y_max = h



for i in range(n):

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

    if a == 1:

        if x > x_min:

            x_min = x

    elif a == 2:

        if x < x_max:

            x_max = x

    elif a == 3:

        if y > y_min:

            y_min = y

    else:

        if y < y_max:

            y_max = y



if x_min > x_max or y_min > y_max:

    print((0))

else:

    print(((x_max-x_min)*(y_max-y_min)))
w, h, n = list(map(int, input().split()))
# 座標用配列
s = [[1 for i in range(w)] for j in range(h)]
# 標準入力
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for j in range(h):
            s[j][0:x] = [0 for k in range(x)]
    elif a == 2:
        for j in range(h):
            s[j][x:w] = [0 for k in range(x, w)]
    elif a == 3:
        for j in range(y):
            s[j] = [0 for k in range(w)]
    elif a == 4:
        for j in range(y, h):
            s[j] = [0 for k in range(w)]
cnt = 0
for i in s:
    cnt += sum(i)
print(cnt)

w, h, n = list(map(int, input().split()))
x_min = 0
x_max = w
y_min = 0
y_max = h
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        if x > x_min:
            x_min = x
    elif a == 2:
        if x < x_max:
            x_max = x
    elif a == 3:
        if y > y_min:
            y_min = y
    else:
        if y < y_max:
            y_max = y
if x_min > x_max or y_min > y_max:
    print((0))
else:
    print(((x_max - x_min) * (y_max - y_min)))

-# 座標用配列 -s = [[1 for i in range(w)] for j in range(h)] -# 標準入力 +x_min = 0 +x_max = w +y_min = 0 +y_max = h -        for j in range(h): -            s[j][0:x] = [0 for k in range(x)] +        if x > x_min: +            x_min = x -        for j in range(h): -            s[j][x:w] = [0 for k in range(x, w)] +        if x < x_max: +            x_max = x -        for j in range(y): -            s[j] = [0 for k in range(w)] -    elif a == 4: -        for j in range(y, h): -            s[j] = [0 for k in range(w)] -cnt = 0 -for i in s: -    cnt += sum(i) -print(cnt) +        if y > y_min: +            y_min = y +    else: +        if y < y_max: +            y_max = y +if x_min > x_max or y_min > y_max: +    print((0)) +else: +    print(((x_max - x_min) * (y_max - y_min)))