from sys import setrecursionlimit
setrecursionlimit(10000)
m,n,k = map(int, input().split())
map_ = [[0 for i in range(m)] for i in range(n)]
areas = []
def is_valid(x,y):
if x >= 0 and y >= 0 and x < n and y < m :
return True
return False
def dfs(x,y):
if not is_valid(x,y) :
return False
global cnt
if map_[x][y] == 0 :
map_[x][y] = 1
dfs(x+1,y)
dfs(x-1,y)
dfs(x,y+1)
dfs(x,y-1)
cnt += 1
return True
return False
def draw_rectangle(s):
s_x, s_y, e_x, e_y = s
for x in range(s_x , e_x):
for y in range(s_y , e_y):
map_[x][y] = 1
for _ in range(k):
s = list(map(int, input().split()))
draw_rectangle(s)
for x in range(n):
for y in range(m):
cnt = 0
if map_[x][y] == 0:
dfs(x,y)
areas.append(cnt)
print(len(areas))
print(*sorted(areas))