main=interact$f.init f s@(x:t)=(do(a,b)<-zip(s:map(:(t>>" "))(r s))s;a++b:"\n")++x:r s r=reverse