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())
a = [0,0] 
b = [w,h] 

for i in range(n):
    x,y,z = map(int,input().split())
    if z==1 and a[0]<x:
        a[0] = x
    elif z==2 and b[0]>x:
        b[0] = x
    elif z==3 and a[1]<y:
        a[1] = y
    elif z==4 and b[1]>y:
        b[1] = y
    print(a,b)
if a[0]<b[0] and a[1]<b[1]:
    print((b[0]-a[0])*(b[1]-a[1]))
else:
    print(0)
w,h,n = map(int,input().split())
a = [0,0] 
b = [w,h] 

for i in range(n):
    x,y,z = map(int,input().split())
    if z==1 and a[0]<x:
        a[0] = x
    elif z==2 and b[0]>x:
        b[0] = x
    elif z==3 and a[1]<y:
        a[1] = y
    elif z==4 and b[1]>y:
        b[1] = y
if a[0]<b[0] and a[1]<b[1]:
    print((b[0]-a[0])*(b[1]-a[1]))
else:
    print(0)