W,H,N = list(map(int,input().split()))



CoordinateList = []

for i in range(N):

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

    CoordinateList.append([x,y,a])



# raw White & Black

AllArea = []

for numline in range(H):

    rawWhite = []

    rawBlack = []

    for numraw in range(W):

        rawWhite.append("W")

        rawBlack.append("B")

    AllArea.append(rawWhite)



# coloring from white to Black

for n in range(N):

    if CoordinateList[n][2] == 1:

        if CoordinateList[n][0] == 0:

             pass

        else:

            for i in range(H):

                del AllArea[i][:(CoordinateList[n][0])]

                for numX in range(CoordinateList[n][0]):

                    AllArea[i].insert(0,"B")



    elif CoordinateList[n][2] == 2:

        if CoordinateList[n][0] == 0:

            print((0))

            exit()

        else:

            for i in range(H):

                del AllArea[i][(CoordinateList[n][0]):]

                for numX in range(CoordinateList[n][0]):

                    AllArea[i].append("B")



    elif CoordinateList[n][2] == 3:

        changeY = H - int(CoordinateList[n][1])

        if changeY == 0:

            print((0))

            exit()

        else:

            del AllArea[changeY:]

            

            for changeRaw in range(int(CoordinateList[n][1])):

                AllArea.append(rawBlack)

            



    elif CoordinateList[n][2] == 4:

        changeY = H - int(CoordinateList[n][1]) 

        if changeY == 0:

            pass

        else:

            del AllArea[:changeY]

            for changeRaw in range(changeY):

                AllArea.insert(0,rawBlack)

            

# counting 

AreaWhite = 0

for i in range(H):

    AreaWhite += AllArea[i].count("W")



print(AreaWhite)
W,H,N = list(map(int,input().split()))



CoordinateList1 = []

CoordinateList2 = []

CoordinateList3 = []

CoordinateList4 = []

for i in range(N):

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

    if a == 1:

        CoordinateList1.append(x)

    elif a == 2:

        CoordinateList2.append(x)

    elif a == 3:

        CoordinateList3.append(y)

    elif a == 4:

        CoordinateList4.append(y)

# X

a1 = 0

if sorted(CoordinateList1) != []:

    a1 = sorted(CoordinateList1)[-1]

a2 = W

if sorted(CoordinateList2) != []:

    a2 = sorted(CoordinateList2)[0]



# Y

a3 = 0

if sorted(CoordinateList3) != []:

    a3 = sorted(CoordinateList3)[-1]

a4 = H

if sorted(CoordinateList4) != []:

    a4 = sorted(CoordinateList4)[0]



if (int(a2)-int(a1)) > 0 and (int(a4)-int(a3)) > 0:

    print(((int(a2)-int(a1))*(int(a4)-int(a3))))

else:

    print((0))
W, H, N = list(map(int, input().split()))
CoordinateList = []
for i in range(N):
    x, y, a = list(map(int, input().split()))
    CoordinateList.append([x, y, a])
# raw White & Black
AllArea = []
for numline in range(H):
    rawWhite = []
    rawBlack = []
    for numraw in range(W):
        rawWhite.append("W")
        rawBlack.append("B")
    AllArea.append(rawWhite)
# coloring from white to Black
for n in range(N):
    if CoordinateList[n][2] == 1:
        if CoordinateList[n][0] == 0:
            pass
        else:
            for i in range(H):
                del AllArea[i][: (CoordinateList[n][0])]
                for numX in range(CoordinateList[n][0]):
                    AllArea[i].insert(0, "B")
    elif CoordinateList[n][2] == 2:
        if CoordinateList[n][0] == 0:
            print((0))
            exit()
        else:
            for i in range(H):
                del AllArea[i][(CoordinateList[n][0]) :]
                for numX in range(CoordinateList[n][0]):
                    AllArea[i].append("B")
    elif CoordinateList[n][2] == 3:
        changeY = H - int(CoordinateList[n][1])
        if changeY == 0:
            print((0))
            exit()
        else:
            del AllArea[changeY:]
            for changeRaw in range(int(CoordinateList[n][1])):
                AllArea.append(rawBlack)
    elif CoordinateList[n][2] == 4:
        changeY = H - int(CoordinateList[n][1])
        if changeY == 0:
            pass
        else:
            del AllArea[:changeY]
            for changeRaw in range(changeY):
                AllArea.insert(0, rawBlack)
# counting
AreaWhite = 0
for i in range(H):
    AreaWhite += AllArea[i].count("W")
print(AreaWhite)

W, H, N = list(map(int, input().split()))
CoordinateList1 = []
CoordinateList2 = []
CoordinateList3 = []
CoordinateList4 = []
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        CoordinateList1.append(x)
    elif a == 2:
        CoordinateList2.append(x)
    elif a == 3:
        CoordinateList3.append(y)
    elif a == 4:
        CoordinateList4.append(y)
# X
a1 = 0
if sorted(CoordinateList1) != []:
    a1 = sorted(CoordinateList1)[-1]
a2 = W
if sorted(CoordinateList2) != []:
    a2 = sorted(CoordinateList2)[0]
# Y
a3 = 0
if sorted(CoordinateList3) != []:
    a3 = sorted(CoordinateList3)[-1]
a4 = H
if sorted(CoordinateList4) != []:
    a4 = sorted(CoordinateList4)[0]
if (int(a2) - int(a1)) > 0 and (int(a4) - int(a3)) > 0:
    print(((int(a2) - int(a1)) * (int(a4) - int(a3))))
else:
    print((0))

-CoordinateList = [] +CoordinateList1 = [] +CoordinateList2 = [] +CoordinateList3 = [] +CoordinateList4 = [] -    CoordinateList.append([x, y, a]) -# raw White & Black -AllArea = [] -for numline in range(H): -    rawWhite = [] -    rawBlack = [] -    for numraw in range(W): -        rawWhite.append("W") -        rawBlack.append("B") -    AllArea.append(rawWhite) -# coloring from white to Black -for n in range(N): -    if CoordinateList[n][2] == 1: -        if CoordinateList[n][0] == 0: -            pass -        else: -            for i in range(H): -                del AllArea[i][: (CoordinateList[n][0])] -                for numX in range(CoordinateList[n][0]): -                    AllArea[i].insert(0, "B") -    elif CoordinateList[n][2] == 2: -        if CoordinateList[n][0] == 0: -            print((0)) -            exit() -        else: -            for i in range(H): -                del AllArea[i][(CoordinateList[n][0]) :] -                for numX in range(CoordinateList[n][0]): -                    AllArea[i].append("B") -    elif CoordinateList[n][2] == 3: -        changeY = H - int(CoordinateList[n][1]) -        if changeY == 0: -            print((0)) -            exit() -        else: -            del AllArea[changeY:] -            for changeRaw in range(int(CoordinateList[n][1])): -                AllArea.append(rawBlack) -    elif CoordinateList[n][2] == 4: -        changeY = H - int(CoordinateList[n][1]) -        if changeY == 0: -            pass -        else: -            del AllArea[:changeY] -            for changeRaw in range(changeY): -                AllArea.insert(0, rawBlack) -# counting -AreaWhite = 0 -for i in range(H): -    AreaWhite += AllArea[i].count("W") -print(AreaWhite) +    if a == 1: +        CoordinateList1.append(x) +    elif a == 2: +        CoordinateList2.append(x) +    elif a == 3: +        CoordinateList3.append(y) +    elif a == 4: +        CoordinateList4.append(y) +# X +a1 = 0 +if sorted(CoordinateList1) != []: +    a1 = sorted(CoordinateList1)[-1] +a2 = W +if sorted(CoordinateList2) != []: +    a2 = sorted(CoordinateList2)[0] +# Y +a3 = 0 +if sorted(CoordinateList3) != []: +    a3 = sorted(CoordinateList3)[-1] +a4 = H +if sorted(CoordinateList4) != []: +    a4 = sorted(CoordinateList4)[0] +if (int(a2) - int(a1)) > 0 and (int(a4) - int(a3)) > 0: +    print(((int(a2) - int(a1)) * (int(a4) - int(a3)))) +else: +    print((0))