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:
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.io.*;
import java.util.*;

public class EC9C
{

private static StringTokenizer st;
    
    public static void nextLine(BufferedReader br) throws IOException
    {
        st = new StringTokenizer(br.readLine());
    }
    
    public static int nextInt()
    {
        return Integer.parseInt(st.nextToken());
    }
    
    public static String next()
    {
        return st.nextToken();
    }
    
    public static long nextLong()
    {
        return Long.parseLong(st.nextToken());
    }

    public static double nextDouble()
    {
        return Double.parseDouble(st.nextToken());
    }
    
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        nextLine(br);
        int n = nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++)
        {
            nextLine(br);
            s[i] = next();
        }
        Comparator<String> comp = new Comparator<String>()
                {

                    @Override
                    public int compare(String s1, String s2)
                    {
                        int len = s1.length() + s2.length();
                        for (int i = 0; i < len; i++)
                        {
                            char q1 = i >= s1.length() ? s2.charAt(i - s1.length()) : s1.charAt(i);
                            char q2 = i >= s2.length() ? s1.charAt(i - s2.length()) : s2.charAt(i);
                            if (q1 != q2)
                            {
                                return q1 - q2;
                            }
                        }
                        return 0;
                    }
            
                };
        Arrays.sort(s, comp);
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < n; i++)
        {
            sb.append(s[i]);
        }
        System.out.println(sb.toString());
    }

    
}