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