Problem: You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.

Given the list of strings, output the lexicographically smallest concatenation.

Input

The first line contains integer n — the number of strings (1 ≤ n ≤ 5·104).

Each of the next n lines contains one string ai (1 ≤ |ai| ≤ 50) consisting of only lowercase English letters. The sum of string lengths will not exceed 5·104.

Output

Print the only string a — the lexicographically smallest string concatenation.

Examples

Input

4
abba
abacaba
bcd
er


Output

abacabaabbabcder


Input

5
x
xx
xxa
xxaa
xxaaa


Output

xxaaaxxaaxxaxxx


Input

3
c
cb
cba


Output

cbacbc

Solution (in JAVA):

Solution:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package CP;
import java.io.*;
import java.util.*;
public class C632 implements Comparable<C632>{
    String str;
    public C632(String s)
    {
        this.str=s;
    }
    public int compareTo(C632 ob)
    {
        int r=0;
        
        /*String max="",min="";
        int r=0,j=0;
        int len1=ob.str.length(),len2=this.str.length();
        if(len1>=len2)
        {
            
            for(int i=0;i<len1;i++)
            {
                char ch1=this.str.charAt(j);
                char ch2=ob.str.charAt(i);
                j=(j+1)%len2;
                if(ch1<ch2)
                {
                    r=-1;
                    break;
                }
                if(ch1>ch2)
                {
                    r=1;
                    break;
                }
            }
        }
        else
        {
            for(int i=0;i<len2;i++)
            {
                char ch1=this.str.charAt(i);
                char ch2=ob.str.charAt(j);
                j=(j+1)%len1;
                if(ch1<ch2)
                {
                    r=-1;
                    break;
                }
                if(ch1>ch2)
                {
                    r=1;
                    break;
                }
            }
        }*/
        return (this.str+ob.str).compareTo(ob.str+this.str);
    }
    public static void main(String args[])throws IOException
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        List<C632> list=new ArrayList<>();
        for(int i=0;i<n;i++)
        {
            list.add(new C632(sc.next()));
        }
        Collections.sort(list);
        for(int i=0;i<n;i++)
        {
            System.out.print(list.get(i).str);
        }
    }
    
}