#!/bin/bash
export LC_ALL=C

echo '
{
	s=$1<3?2:$1-1
	t=w<$1+1?w:$1+1
	u=$2<3?2:$2-1
	v=h<$2+1?h:$2+1
	for(i=s;i<=t;i++)for(j=u;j<=v;j++)a[i,j]++
}
END{
	for(i in a)print i,a[i]

}
' >./arc061_d.f

_awk(){ awk -v w=$w -v h=$h -f arc061_d.f  ;}
read w h n
((--w));((--h))
rm -rf ./pipe*
mkfifo pipe{0..7}

echo |tee pipe{0..6} >pipe7 &
cat|awk '{print >> "./pipe"NR%8}' &
awk -v w=$w -v h=$h '{a[$1]+=$2}END{for(i in a)b[a[i]]++;for(i=1;i<=9;i++)printf "%d\n",b[i] |"cat";for(i=1;i<=9;i++)printf "-%d",b[i] |"eval echo \$\(\("(w-1)"*"(h-1)"\`cat\`\)\)"}' <(_awk<pipe0) <(_awk<pipe1) <(_awk<pipe2) <(_awk<pipe3) <(_awk<pipe4) <(_awk<pipe5) <(_awk<pipe6) <(_awk<pipe7)
wait
exit