a=gets(r=([s='H-O-'*6+?H,t=' | '*6+u=' ',' H '*6+u,t]*5<<s)*$/).split 6.times{|i|k=1 l=6 5.times{|j|r[i*104-k-=4+a[i*6+j].hex*2]=r[4.*i-l-=26-a[j*6+i].hex*13]=u}} $><<r
Note that non-ascii characters in the above source code will be escaped (such as \x9f).