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())
xya=[[int(i) for i in input().split()] for j in range(n)]

minx=w
maxx=0
miny=h
maxy=0
for x,y,a in xya:
    if a==2:
        maxx=max(maxx,x)
    elif a==1:
        minx=min(minx,x)
    elif a==4:
        maxy=max(maxy,y)
    elif a==3:
        miny=min(miny,y)

x=max(0,maxx-minx)
y=max(0,maxy-miny)
print(x*y)
w,h,n=map(int,input().split())
xya=[[int(i) for i in input().split()] for j in range(n)]

minx=w
maxx=0
miny=h
maxy=0
for x,y,a in xya:
    if a==1:
        maxx=max(maxx,x)
    elif a==2:
        minx=min(minx,x)
    elif a==3:
        maxy=max(maxy,y)
    elif a==4:
        miny=min(miny,y)

x=max(0,minx-maxx)
y=max(0,miny-maxy)
print(x*y)