t=strsplit h=length p=a="" for(b in t(readLines("stdin"),p)){a=unlist(t(paste(b,a,sep=p),p))[-2*max(h(b),h(a)+1)] cat(a," ",sep=p)}