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.
sorce_point = list(map(int, input().split()))
W = sorce_point[0]
H = sorce_point[1]
N = sorce_point[2]

point = []
for i in range(N):
	point.append(list(map(int, input().split())))
point.append(sorce_point)
for i in range(N + 1):
	if (point[i][2] == 1):
		for j in range(N):
			if point[j][0] < point[i][0]:
				point[j][0] = 0
				point[j][1] = 0
	if (point[i][2] == 2):
		for j in range(N + 1):
			if point[j][0] > point[i][0]:
				point[j][0] = 0
				point[j][1] = 0
	if (point[i][2] == 3):
		for j in range(N + 1):
			if point[j][1] < point[i][1]:
				point[j][1] = 0
	if (point[i][2] == 4):
		for j in range(N + 1):
			if point[j][1] > point[i][1]:
				point[j][1] = 0

point.append(sorce_point)
print(point)
mx= 0
my = 0
mix = 100
miy = 100
for i in range(N + 1):
	if mx < point[i][0]:
		mx = point[i][0]
	if my < point[i][1]:
		my = point[i][1]
	if mix > point[i][0] and not(point[i][0] == 0):
		mix = point[i][0]
	if miy > point[i][1] and not(point[i][1] == 0):
		miy = point[i][1]

print((mx - mix) * (my - miy))

W, H, N = map(int, input().split())
w, h = 0, 0

for i in range(N):
	x, y, a = map(int, input().split())

	if a == 1 and w < x:
		w = x
	elif a == 2 and W > x:
		W = x
	elif a == 3 and h < y:
		h = y
	elif a == 4 and H > y:
		H = y

if W - w <= 0 or H - h <= 0:
	print(0)
else:
	print((W - w) * (H - h))