import sys
sys.setrecursionlimit(10**7)
m,n,k = list(map(int, input().split()))
arr=[[0]*(n+1) for _ in range(m+1)]
for _ in range(k):
x1,y1,x2,y2= (map(int, input().split()))
for i in range(y1,y2):
for j in range(x1, x2):
arr[i][j] = 1
def dfs(x,y):
if x<0 or x>n-1 or y<0 or y>m-1:
return 0
if arr[y][x]:
return 0
arr[y][x]=1
return 1 + dfs(x-1,y) + dfs(x+1,y) + dfs(x,y-1) + dfs(x,y+1)
cnt=[]
for i in range(m):
for j in range(n):
if arr[i][j] ==0:
cnt.append(dfs(x=j, y=i))
print(len(cnt))
print(*sorted(cnt))