//#include<stdio.h>
//int main()
//{
// long long int n, arr[3001]={}, t[3001]={}, x=0,i=1,j=1, min=10000000, temp[2]={},wich=0;
// scanf("%lld", &n);
// i=1;
// while(i<=n)
// {
// scanf("%lld", &arr[i]);
// i++;
// }
// i=1;
// while(i<=n)
// {
// scanf("%lld", &t[i]);
// i++;
// }
// i=1;
// while(i<n)
// {
// min = i;
// j = i;
// while(j<=n)
// {
// if (t[min]>t[j])
// {
// min = j;
// }
// j++;
// }
// temp[0] = arr[i];
// temp[1] = t[i];
// arr[i] = arr[min];
// t[i] = t[min];
// arr[min] = temp[0];
// t[min] = temp[1];
// i++;
// }
// i = 1;
// while(i<=n)
// {
// if (wich>arr[i])
// {
// temp[0] = wich-arr[i];
// }
// else
// {
// temp[0] = arr[i]-wich;
// }
// if (temp[0]>t[i])
// {
// x+=temp[0];
// temp[1] = temp[0];
// wich += arr[i]-wich;
// }
// else
// {
// x+=temp[0]+(t[i]-temp[0]);
// temp[1] = temp[0]+(t[i]-temp[0]);
// wich += arr[i]-wich;
// }
// j=1;
// while(j<=n)
// {
// t[j]-= temp[1];
// if (t[j] < 0)
// {
// t[j] = 0;
// }
// j++;
// }
// i++;
// }
// x+=wich;
// printf("%lld", x);
// return 0;
//}
#include <stdio.h>
int min=1,temp,r,e[1001]={},n,m,arr[150][150] = {},i,j,k;
int y1[200]={}, x1[200]={}, y2[200]={}, x2[200]={}, t=0;
void f(int y, int x)
{
if (arr[y][x]==0)
{
e[r]++;
arr[y][x] = 3;
f(y+1, x);
f(y-1, x);
f(y, x+1);
f(y, x-1);
}
return;
}
int main()
{
scanf("%d %d %d", &n, &m, &k);
for(i=1;i<=k;i++)
{
scanf("%d %d %d %d", &x1[i],&y1[i],&x2[i],&y2[i]);
x1[i]+=1;
y1[i]+=1;
}
for(i=0;i<=n+1;i++)
{
for(j=0;j<=m+1;j++)
{
if (i==0||i==n+1||j==0||j==m+1)
{
arr[i][j] = 1;
}
}
}
for(t=1;t<=k;t++)
{
for(i=y1[t];i<=y2[t];i++)
{
for(j=x1[t];j<=x2[t];j++)
{
arr[i][j] = 1;
}
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if (arr[i][j] == 0)
{
r+=1;
f(i, j);
}
}
}
for(i=1;i<r;i++)
{
min = i;
for(j=i;j<=r;j++)
{
if (e[min]>e[j])
{
min = j;
}
}
temp = e[i];
e[i] = e[min];
e[min] = temp;
}
printf("%d\n", r);
for(i=1;i<=r;i++)
{
printf("%d ", e[i]);
}
return 0;
}