$"='';$/=\1;@_=<>;map{@a=@_,@a[$',$_]=@_[$_,$'],$\<"@a"?$\="@a":0for//..@_-2}0..@_;print