n=3 while 1: \x09r=input();n-=1 \x09if'0'<r[2]:a,b=map(int,r.split());p=q=2-n//a;exec("q+=1;print(((' +|'+l//b*'- '+'+|')[q%p>1::2]*b)[1:]);"*p*a);n=3 \x09l=len(r)-2
Note that non-ascii characters in the above source code will be escaped (such as \x9f).