using C=System.Console;class M{static void Main(){for(int d=C.Read()%8,n=1-d*5%12,i=5,j=5;i-->n*4;)C.Write(i>n?i<0?""+d:" ":i<n?i>n*2?"_":i>n*3?i%n<0?"0":"\n9 | "+d:"\n{0,"+j+(j<5-n?"}0\n{1,"+(j-2)+"}{2,3}\n{3,"+j+++"}_":"}"):"\n ___",d,'-',d*9,'_');}}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).