Bob has a rectangular chocolate bar of the size W × H. He introduced a cartesian coordinate system so that the point (0, 0) corresponds to the lower-left corner of the bar, and the point (W, H) corresponds to the upper-right corner. Bob decided to split the bar into pieces by breaking it. Each break is a segment parallel to one of the coordinate axes, which connects the edges of the bar. More formally, each break goes along the line x = xc or y = yc, where xc and yc are integers. It should divide one part of the bar into two non-empty parts. After Bob breaks some part into two parts, he breaks the resulting parts separately and independently from each other. Also he doesn't move the parts of the bar. Bob made n breaks and wrote them down in his notebook in arbitrary order. At the end he got n + 1 parts. Now he wants to calculate their areas. Bob is lazy, so he asks you to do this task.

Input

The first line contains 3 integers W, H and n (1 ≤ W, H, n ≤ 100) — width of the bar, height of the bar and amount of breaks. Each of the following n lines contains four integers xi, 1, yi, 1, xi, 2, yi, 2 — coordinates of the endpoints of the i-th break (0 ≤ xi, 1 ≤ xi, 2 ≤ W, 0 ≤ yi, 1 ≤ yi, 2 ≤ H, or xi, 1 = xi, 2, or yi, 1 = yi, 2). Breaks are given in arbitrary order.

It is guaranteed that the set of breaks is correct, i.e. there is some order of the given breaks that each next break divides exactly one part of the bar into two non-empty parts.

Output

Output n + 1 numbers — areas of the resulting parts in the increasing order.

Examples

Input

2 2 2
1 0 1 2
0 1 1 1


Output

1 1 2 

Input

2 2 3
1 0 1 2
0 1 1 1
1 1 2 1


Output

1 1 1 1 

Input

2 4 2
0 1 2 1
0 3 2 3


Output

2 2 4

Source: codeforces | Difficulty: HARD
Tags: Graph traversal

Implementation


Solutions:
(w, h, n) = list(map(int, input().split()))
a = [[0 for i in range(2 * w - 1)] for j in range(2 * h - 1)]
for i in range(1, 2 * h - 1, 2):
	for j in range(1, 2 * w - 1, 2):
		a[i][j] = ' '
for i in range(n):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	if x1 == x2:
		if x1 != 0 and x1 != w:
			for j in range(min(y1, y2), max(y1, y2)):
				a[2 * h - 2 - 2 * j][2 * x1 - 1] = ' '
	elif y1 != 0 and y1 != h:
		for j in range(min(x1, x2), max(x1, x2)):
			a[2 * h - 1 - 2 * y1][2 * j] = ' '
b = []
c = 1
for i in range(0, 2 * h - 1, 2):
	for j in range(0, 2 * w - 1, 2):
		if a[i][j] == 0:
			d = i
			e = j
			while d < 2 * h - 1 and a[d][e] == 0 and (a[d - 1][e] != ' ') or d == i:
				d += 2
			d -= 2
			while e < 2 * w - 1 and a[d][e] == 0 and (a[d][e - 1] != ' ') or e == j:
				e += 2
			e -= 2
			b.append(((e - j) // 2 + 1) * ((d - i) // 2 + 1))
			for k in range(i, d + 1, 2):
				for l in range(j, e + 1, 2):
					a[k][l] = c
			c += 1
b += [0] * (n + 1 - len(b))
print(*sorted(b))


import sys
from array import array

def input():
	return sys.stdin.buffer.readline().decode('utf-8')
(w, h, n) = map(int, input().split())
mat = [[0] * (2 * w) for _ in range(2 * h)]
for (x1, y1, x2, y2) in (map(int, input().split()) for _ in range(n)):
	if x1 == x2:
		for y in range(2 * y1, 2 * y2):
			mat[y][2 * x1 - 1] = 1
	else:
		for x in range(2 * x1, 2 * x2):
			mat[2 * y1 - 1][x] = 1
ans = []
for i in range(0, 2 * h, 2):
	for j in range(0, 2 * w, 2):
		if mat[i][j]:
			continue
		mat[i][j] = 1
		size = 1
		stack = [(i, j)]
		while stack:
			(y, x) = stack.pop()
			for (dy, dx) in ((1, 0), (-1, 0), (0, 1), (0, -1)):
				if 0 <= y + dy * 2 < 2 * h and 0 <= x + dx * 2 < 2 * w and (mat[y + dy][x + dx] == 0) and (mat[y + dy * 2][x + dx * 2] == 0):
					mat[y + dy * 2][x + dx * 2] = 1
					size += 1
					stack.append((y + dy * 2, x + dx * 2))
		ans.append(size)
print(*sorted(ans))


(w, h, n) = map(int, input().split(' '))
hblock = [[False for i in range(w)] for i in range(h)]
vblock = [[False for i in range(w)] for i in range(h)]
for i in range(n):
	(x1, y1, x2, y2) = map(int, input().split(' '))
	if x1 == x2:
		for j in range(y1, y2):
			hblock[j][x1 - 1] = True
	else:
		for j in range(x1, x2):
			vblock[y1 - 1][j] = True
areas = []
vis = [[False for i in range(w)] for i in range(h)]
for i in range(h):
	for j in range(w):
		if vis[i][j]:
			continue
		width = j
		while width < w and (not hblock[i][width]):
			width += 1
		height = i
		while height < h and (not vblock[height][j]):
			height += 1
		width = min(w - 1, width) - j + 1
		height = min(h - 1, height) - i + 1
		areas.append(width * height)
		for p in range(height):
			for q in range(width):
				vis[i + p][j + q] = True
areas.sort()
print(' '.join(map(str, areas)))


WHn = [[0, 0]]
WHn[0].extend([int(x) for x in input().split(' ')])
n = range(WHn[0][-1])
lines = []
lines_aux = []
for i in n:
	lines.append([int(x) for x in input().split(' ')])
	lines_aux.append(True)
while any(lines_aux):
	for i in n:
		if lines_aux[i]:
			for unidad in WHn:
				rangex = range(unidad[0], unidad[2] + 1)
				rangey = range(unidad[1], unidad[3] + 1)
				if lines[i][0] in rangex and lines[i][3] in rangey and (lines[i][2] in rangex) and (lines[i][1] in rangey) and (lines[i][0:3:2] == unidad[0:3:2] or lines[i][1:4:2] == unidad[1:4:2]):
					WHn.append([unidad[0], unidad[1], lines[i][2], lines[i][3]])
					WHn.append([lines[i][0], lines[i][1], unidad[2], unidad[3]])
					WHn.remove(unidad)
					lines_aux[i] = False
					break
for (i, unidad) in enumerate(WHn):
	WHn[i] = (unidad[2] - unidad[0]) * (unidad[3] - unidad[1])
WHn.sort()
result = ''
for i in WHn:
	result += '{} '
print(result[:-1].format(*WHn))