o=S='-'*17 System.in.eachLine{n=it as Byte v=n>8?5533:n>5?381:n>3?29:0 u=[7,29,381,0,7,0,4,74,7,59][n-1] 271.times{i->d=-4 z=!0 o+=i%18?[v,u,v].any{for(d+=6;it;it>>=4)z&=(i<(k=it%16*18+d)|k+2<i)&&i-k+17&&i-k-19 !z}?'*':' ':'\n'} o+=S} print o
Note that non-ascii characters in the above source code will be escaped (such as \x9f).