import numpy as np

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



g = np.array([[1] * W for _ in range(H)])



for _ in range(N):

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

    if a == 1:

        g[:,:x] = 0

    elif a == 2:

        g[:,x:] = 0

    elif a == 3:

        g[H - y:,:] = 0

    elif a == 4:

        g[:H - y,:] = 0



print((g.sum()))



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



G = [[1] * H for _ in range(W)]



for _ in range(N):

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



    if a == 1:

        for x_ in range(x):

            for y_ in range(H):

                G[x_][y_] = 0



    if a == 2:

        for x_ in range(x, W):

            for y_ in range(H):

                G[x_][y_] = 0

    

    if a == 3:

        for x_ in range(W):

            for y_ in range(y):

                G[x_][y_] = 0

    

    if a == 4:

        for x_ in range(W):

            for y_ in range(y, H):

                G[x_][y_] = 0



ans = 0

for g in G:

    # print (g)

    ans += sum(g)



print (ans)
import numpy as np

W, H, N = list(map(int, input().split()))
g = np.array([[1] * W for _ in range(H)])
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        g[:, :x] = 0
    elif a == 2:
        g[:, x:] = 0
    elif a == 3:
        g[H - y :, :] = 0
    elif a == 4:
        g[: H - y, :] = 0
print((g.sum()))
# print (g)

W, H, N = list(map(int, input().split()))
G = [[1] * H for _ in range(W)]
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for x_ in range(x):
            for y_ in range(H):
                G[x_][y_] = 0
    if a == 2:
        for x_ in range(x, W):
            for y_ in range(H):
                G[x_][y_] = 0
    if a == 3:
        for x_ in range(W):
            for y_ in range(y):
                G[x_][y_] = 0
    if a == 4:
        for x_ in range(W):
            for y_ in range(y, H):
                G[x_][y_] = 0
ans = 0
for g in G:
    # print (g)
    ans += sum(g)
print(ans)

-import numpy as np - -g = np.array([[1] * W for _ in range(H)]) +G = [[1] * H for _ in range(W)] -        g[:, :x] = 0 -    elif a == 2: -        g[:, x:] = 0 -    elif a == 3: -        g[H - y :, :] = 0 -    elif a == 4: -        g[: H - y, :] = 0 -print((g.sum())) -# print (g) +        for x_ in range(x): +            for y_ in range(H): +                G[x_][y_] = 0 +    if a == 2: +        for x_ in range(x, W): +            for y_ in range(H): +                G[x_][y_] = 0 +    if a == 3: +        for x_ in range(W): +            for y_ in range(y): +                G[x_][y_] = 0 +    if a == 4: +        for x_ in range(W): +            for y_ in range(y, H): +                G[x_][y_] = 0 +ans = 0 +for g in G: +    # print (g) +    ans += sum(g) +print(ans)