@@ -0,0 +1,681 @@
+import java.util.*;%0Aclass Main %7B%0A    public static void main(String%5B%5Da)throws Exception %7B%0A        byte%5B%5Db=new byte%5B20000%5D;System.in.read(b);%0A        String%5B%5Dw=new String(b).split(%22%5C%5Cs%22);%0A        StringBuilder x=new StringBuilder(9000),c=new StringBuilder();%0A        int n=Integer.parseInt(w%5B0%5D),i,j;%0A        Arrays.sort(w,1,n+1);%0A        Set%3CString%3Et=new HashSet%3C%3E();%0A        for(i=1;i%3C=n;i++)t.add(w%5Bi%5D);%0A        for(i=1;i%3C=n;i++)%7B%0A            String v=w%5Bi%5D,r=new StringBuilder(v).reverse().toString();%0A            if(r.equals(v))c.append(r);%0A            else if(t.contains(r)&&v.compareTo(r)%3C0)x.append(v);%0A        %7D%0A        System.out.print(x.toString()+c+x.reverse());%0A    %7D%0A%7D%0A

Create test2.java