while 1:x=n=input();exec"k=x/n%4;x+=1;c=' _'[k>x%n<1]*n;print' | '[-k]+c+('|'+c+k/3*'|').strip();"*4*n