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 thesmalleststringconcatenation;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

/**
 *
 * @author PrudhviNIT
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    
    static int compares(String o1, String o2) {
                for(int i=0;i<o1.length()&&i<o2.length();i++){
                    if(o1.charAt(i)<o2.charAt(i)){
                        return -1;
                    }
                    if(o1.charAt(i)>o2.charAt(i)){
                        return 1;
                    }
                }
                if(o1.length()>o2.length()){
                    for(int i=o2.length();i<o1.length();i++){
                        if(o1.charAt(i)<o2.charAt(o2.length()-1)){
                            return -1;
                        }
                        if(o1.charAt(i)>o2.charAt(o2.length()-1)){
                            return 1;
                        }
                    }
                }
                else{
                    for(int i=o1.length();i<o2.length();i++){
                        if(o2.charAt(i)<o1.charAt(o1.length()-1)){
                            return 1;
                        }
                        if(o2.charAt(i)>o1.charAt(o1.length()-1)){
                            return -1;
                        }
                    }
                }
                return Integer.compare(o2.length(),o1.length());
            }
        
        public static void main(String[] args) throws IOException {
            //System.out.println(compares("ab", "abcdef"));
        // TODO code application logic here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim()),i,j;
        String str[] = new String[n];
        for(i=0;i<n;i++){
            str[i] = br.readLine();
        }
        
        Arrays.sort(str,new Comparator<String>(){
            @Override
            public int compare(String o1, String o2) {
                return (o1+o2).compareTo(o2+o1);
            }
        });
        for(i=0;i<n;i++){
            System.out.print(str[i]);
        }
        System.out.println();
        //System.out.println("abaabaabaacaabaacacacaaaabbacbaacbbbbcabcabbcccaabcc");
    }
    
}