# print('Hello World')
# print('Hello', end=' ')
# print('World')
# print('Hello\nWorld')
# print(10 + 20)
# print('Hello', 'World', 'Apple', sep='\n')
# x = 1000
# print(type(x))
# x = 10
# y = 'Hello'
#
# print(x + y)
# print('\"!@#$%^&*()\'')
# print('\"C:\\Download\\\'hello\'.py\"')
# print('print(\"Hello\\nWorld\")')
# print('Hello', 'World')
# print('\'Hello\'')
# x = input() # string
# x = int(x)
# x = int(input())
# print(x)
#
# x, y = input().split()
# x = int(x)
# y = int(y)
# x, y = map(int, input().split())
# x= int(input())
# y= int(input())
# data = input().split() # list
# print(data)
'''
x = int(x)
x = chr(x)
x = float(x)
x = ord(x)
'''
#6024~6026
# print('Hello', )
# x=float(input())
# print(x)
# a=input()
# b=input()
# print(b)
# print(a)
# x=float(input())
# print(x)
# print(x)
# print(x)
# a, b = map(int, input().split())
# print(a)
# print(b)
# c1, c2 = input().split()
# print(c2, c1)
# s=input()
# print(s, s, s)
# a, b = input().split('-')
# print(a, b, sep='')
# s = input()
# print(s[0:2], s[2:4], s[4:6], sep=' ')
# c1, c2 = input().split(' ')
# print(c1, c2, sep='')
# a, b = map(int, input().split(' '))
# print(a+b)
# f1 = float(input())
# f2 = float(input())
# print(f1+f2)
# n = int(input())
# print('%X'%n)
# n = int(input(), 16)
# print('%o'%n)
# x = 100
# y = 200
#
# print(x+y)
'''
+
-
*
/: 정수/정수 = 실수
%
//: 몫 7//2 = 3
**: 제곱
'''
# x = 3.141592
# print('%.2f %.2f' %(x, x))
'''
&&: and
||: or
!: not
a and b
'''
# x = int(input())
# y = int(input())
# x = bool(x)
# y = bool(y)
#
# print(x and y)
# x = 10
# y = 20
#
# z = x - y if x > y else y - x
# if x > y:
# print('asdasd')
# elif x == y:
# asdasd
# elif dasasd:
# weqqwe
# else:
#
# x = int(input(), 16)
# print('%o'% x)
#
# x=ord(input())
# print(x)
# n=int(input())
# print(chr(n))
# n=int(input())
# print(-n)
#
# n = input()
# n = ord(n)+1
# print(chr(n))
# a, b = map(int, input().split(' '))
# print(a-b)
# f1, f2 = input().split(' ')
# f1 = float(f1)
# f2 = float(f2)
# print(f1*f2)
# w, n = input().split()
# print(w*int(n))
# n = int(input())
# s = input()
# print(s*n)
# a, b = input().split()
# print(int(a)**int(b))
# f1, f2 = input().split()
# print(float(f1)**float(f2))
# a, b = map(int, input().split())
# print(a//b)
# f1 = float(input())
# print('%.2f' %f1)
# f1, f2 = input().split()
# f1 = float(f1)
# f2 = float(f2)
# print('%.4f' %(f1/f2))
# a, b = map(int, input().split())
# print(a+b)
# print(a-b)
# print(a*b)
# print(a//b)
# print(a%b)
# print('%.2f' %(a/b))
# a, b, c = map(int, input().split())
# n = a+b+c
# print(n, end=' ')
# print('%.2f' %(n/3))
# a, b = map(int, input().split())
# print(a < b)
# a = bool(int(input()))
# print(not a)
# a, b = input().split()
# print(bool(int(a)) and bool(int(b)))
# a, b = map(int, input().split())
# a = bool(a)
# b = bool(b)
# print((a and (not b)) or (b and (not a)))
# a, b = map(int, input().split())
# a = bool(a)
# b = bool(b)
# print((a and b) or ((not a) and (not b)))
# a, b = map(int, input().split())
# c = (a if (a>=b) else b)
# print(int(c))
#include <stdio.h>
int map[102][102]={}, area[5000]={}, num=1;
void find(int x, int y)
{
if(map[x][y]==0){
map[x][y]=1;
area[num]=area[num]+1;
find(x, y+1);
find(x, y-1);
find(x+1, y);
find(x-1, y);
}
}
int main(void)
{
int m, n, k, x1, x2, y1, y2, i, j, p, max, tempt;
scanf("%d %d %d", &m, &n, &k);
for(i=0; i<=(n+1); i++){
for(j=0; j<=(m+1); j++){
map[i][j]=1;
}
}
for(i=1; i<=n; i++){
for(j=1; j<=m; j++){
map[i][j]=0;
}
}
for(p=0; p<k; p++){
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
for(i=(x1+1); i<=x2; i++){
for(j=(y1+1); j<=y2; j++){
map[i][j]=1;
}
}
}
for(i=1; i<=n; i++){
for(j=1; j<=m; j++){
if(map[i][j]==0){
find(i, j);
num++;
}
}
}
for(i=(num-1); i>0; i--){
max=i;
for(j=i; j>0; j--){
if(area[max]<area[j]){
max=j;
}
}
tempt=area[i];
area[i]=area[max];
area[max]=tempt;
}
printf("%d\n", (num-1));
for(i=1; i<num; i++){
printf("%d ", area[i]);
}
return 0;
}