export LC_ALL=C;read w h n;((--w));((--h));eval tee '>(awk -vw=$w -vh=$h -vk='{0..7}\ \''NR%8==k{t=w<++$1?w:$1;u=$2<3?2:$2-1;v=h<++$2\
?h:$2;for(i=$1<4?2:$1-2;i<=t;i++)for(j=u;j<=v;j++)print i,j|"dd>>"k;w}'\'\)|dd>__;sort ?|uniq -c|sort|uniq -cw7|awk -vw=$w -vh=$h '{a\
[$2]=$1;t=t"-"$1}END{a[0]=--w"*"--h""t;for(i=0;i<=9;i++)printf"$((%s)) ",a[i]?a[i]:0|"eval echo `dd`"}'|tr \  \\n