There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.  Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).  Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:    * If a_i = 1, he painted the region satisfying x < x_i within the rectangle.   * If a_i = 2, he painted the region satisfying x > x_i within the rectangle.   * If a_i = 3, he painted the region satisfying y < y_i within the rectangle.   * If a_i = 4, he painted the region satisfying y > y_i within the rectangle.  Find the area of the white region within the rectangle after he finished painting.
W,H,N = map(int,input().split())
Data = []
for _ in range(N):
    Data.append(list(map(int,input().split())))

x1,x2 = 0,W
y1,y2 = 0,H

for i in range(N):
    x,y,a = Data[i]
    if a == 1:
        x1 = max(x1,x)
    elif a == 2:
        x2 = min(x2,x)
    elif a == 3:
        y1 = max(y1,y)
    elif a == 4:
        y2 = min(y2,y)
    print(x1,x2,y1,y2)

if x2 >= x1 and y2 >= y1:
    s = (x2-x1)*(y2-y1)
else:
    s = 0
print(s)
W,H,N = map(int,input().split())
Data = []
for _ in range(N):
    Data.append(list(map(int,input().split())))

x1,x2 = 0,W
y1,y2 = 0,H

for i in range(N):
    x,y,a = Data[i]
    if a == 1:
        x1 = max(x1,x)
    elif a == 2:
        x2 = min(x2,x)
    elif a == 3:
        y1 = max(y1,y)
    elif a == 4:
        y2 = min(y2,y)

if x2 >= x1 and y2 >= y1:
    s = (x2-x1)*(y2-y1)
else:
    s = 0
print(s)
