prologues:=2;
input TEX;

beginfig(1);
k:=41;
label(TEX(""&decimal(k)&""),(0,0));
pair ptd;
ptd:=(0,0);
u:=8mm;
for l=1 upto 15:
  if (l mod 2)=1:
    for j=1 upto l:
      k:=k+1;
      label(TEX(""&decimal(k)&""),ptd+u*(0,j));
    endfor;
    ptd:=ptd+u*(0,l);
    for j=1 upto l:
      k:=k+1;
      label(TEX(""&decimal(k)&""),ptd+u*(j,0));
    endfor;
    ptd:=ptd+u*(l,0);
  fi;
  if (l mod 2)=0:
    for j=1 upto l:
      k:=k+1;
      label(TEX(""&decimal(k)&""),ptd+u*(0,-j));
    endfor;
    ptd:=ptd+u*(0,-l);
    for j=1 upto l:
      k:=k+1;
      label(TEX(""&decimal(k)&""),ptd+u*(-j,0));
    endfor;
    ptd:=ptd+u*(-l,0);
  fi;
endfor;
endfig;
end