System.in.eachLine{(a,b)=it.split() a.each{b.each{x->a+=" $it$x"}}println a-~/.+? /}