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.io.*;
import java.util.*;
import java.lang.*;
public class Codechef {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    String f;
	    int s;
 
	    Pair(String t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f.compareTo(p.f);
 
	    	return this.s-p.s;
	    }
 	}
 	class Sort implements Comparator<String> 
	{ 
	    public int compare(String a, String b) 
	    { 
	    	return (a+b).compareTo(b+a);
	    } 
	}
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	// int lowerBound(ArrayList<Pair> a,int key,int n)//s
	// {
	// 	int l=0,r=a.size()-1;
	// 	int i=n;

	// 	while(l<=r)
	// 	{
	// 		int mid=(l+r)/2;

	// 		if(a.get(mid).s<key){
	// 			l=mid+1;
	// 			i=mid+1;
	// 		}

	// 		else 	r=mid-1;
	// 	}
	// 	return i;
	// }
	// int upperBound(ArrayList<Pair> a,int key,int n)
	// {
	// 	int l=0,r=a.size()-1;
	// 	int i=n;

	// 	while(l<=r)
	// 	{
	// 		int mid=(l+r)/2;

	// 		if(a.get(mid).f<=key)	l=mid+1;

	// 		else{
	// 			i=mid;
	// 			r=mid-1;
	// 		}
	// 	}
	// 	return i;
	// }

	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}

	long mod=1000000007;
	String call(String str)
	{
		StringBuilder s = new StringBuilder(str);
		//out.println(s+" funstart");
		while(s.length()<50)
			s.append(s);
		//out.println(s.substring(0,50)+" funstart");
		return s.substring(0,50).toString();
	}

	void solve() throws IOException{
		int n=nextInt();
		PriorityQueue<String> p =new PriorityQueue<>(n,new Sort());
		while(n-->0)
			p.add(ns());

		// for(int i=0;i<4;i++){
		// 	Pair m=p.poll();
		// 	out.println(m.f+" :"+m.s);
		// }
		while(!p.isEmpty())
		{
			out.print(p.poll());
		}
		
	}
  
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();
		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Codechef().run();
	}
  
}