import sys
input = sys.stdin.readline
M, N, K = map(int, input().split())
graph = [[0 for _ in range(N)] for _ in range(M)]
visit = [[0 for _ in range(N)] for _ in range(M)]
k_cnt = []
def dfs(graph, y_root, x_root):
cnt = 0
stack = [[y_root, x_root]]
y = [-1, 1, 0, 0]
x = [0, 0, -1, 1]
while(stack):
index = stack.pop()
visit[index[0]][index[1]] = 1
cnt += 1
for i in range(4):
ny = index[0] + y[i]
nx = index[1] + x[i]
if(0 <= ny < M and 0 <= nx < N):
if(graph[ny][nx] == 0 and visit[ny][nx] == 0):
stack.append([ny, nx])
return cnt
for i in range(K):
x1, y1, x2, y2 = map(int, input().split())
for y in range(y1, y2):
for x in range(x1, x2):
graph[y][x] = 1
for i in range(M):
for j in range(N):
if(graph[i][j] == 0 and visit[i][j] == 0):
k_cnt.append(dfs(graph, i, j))
print(len(k_cnt))
print(*sorted(k_cnt))