/*#include<stdio.h>
int arr[27][27]={},a[100]={0},b=-1;
void qs(int s, int e)
{
int p=s,temp;
int l = s, h=e+1;
do
{
do{ l++;}while(a[p]>a[l]);
do{ h--;}while(a[p]<a[h]);
if(l<h)
{
temp=a[l];
a[l]=a[h];
a[h]=temp;
}
}while(l<h);
temp=a[p];
a[p]=a[h];
a[h]=temp;
if(s<h-1) qs(s,h-1);
if(h+1<e) qs(h+1,e);
}
void dfs(int y,int x)
{
if(arr[y][x]==1)
{
a[b]++;
arr[y][x]=0;
dfs(y+1,x);
dfs(y,x+1);
dfs(y-1,x);
dfs(y,x-1);
}
}
int main()
{
int i,j,n,c=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%1d",&arr[i][j]);
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(arr[i][j]==1)
{
c++;
b++;
dfs(i,j);
}
}
}
qs(0,b);
printf("%d",c);
for(i=0;i<c;i++)
{
printf("\n%d",a[i]);
}
}*/
#include<stdio.h>
int arr[102][102]={},a[100]={},b=-1;
void qs(int s, int e)
{
int p=s,temp;
int l = s, h=e+1;
do
{
do{ l++;}while(a[p]>a[l]);
do{ h--;}while(a[p]<a[h]);
if(l<h)
{
temp=a[l];
a[l]=a[h];
a[h]=temp;
}
}while(l<h);
temp=a[p];
a[p]=a[h];
a[h]=temp;
if(s<h-1) qs(s,h-1);
if(h+1<e) qs(h+1,e);
}
void dfs(int y,int x)
{
if(arr[y][x]==1)
{
a[b]++;
arr[y][x]=0;
dfs(y+1,x);
dfs(y,x+1);
dfs(y-1,x);
dfs(y,x-1);
}
}
int main()
{
int n,m,k,i,j,l,c1,c2,c3,c4,c=0;
scanf("%d %d %d",&m,&n,&k);
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
arr[i][j]=1;
}
}
for(i=0;i<k;i++)
{
scanf("%d %d %d %d",&c1,&c2,&c3,&c4);
for(j=c1+1;j<c3+1;j++)
{
for(l=c2+1;l<c4+1;l++)
{
arr[j][l]=0;
}
}
}
/*for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
printf("%d ",arr[i][j]);
}
printf("\n");
}*/
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(arr[i][j]==1)
{
c++;
b++;
dfs(i,j);
}
}
}
qs(0,b);
printf("%d\n",c);
for(i=0;i<c;i++)
{
printf("%d ",a[i]);
}
}