$"='';$n=@_=<>=~/./g;for$i(0..--$n){@a=@_,@a[$i,$_]=@_[$_,$i],$\<"@a"?$\="@a":0for$i..$n}print