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
import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	static S[] s=new S[50005];
	static class S implements Comparable<S>
	{
		String a;
		S(String x) { a=x;}
		public int compareTo(S b) {
			return (a+b.a).compareTo(b.a+a);
		}
	}
	
	void solve() throws Exception {
		long k,c=0,d,ans=0;
		int n=sc.nextInt();
		for(int i=0;i<n;i++)
		{
			s[i]=new S(sc.nextToken());
		}
		Arrays.sort(s,0,n);
		for (int i=0;i<n;i++)
	    {
			out.print(s[i].a);
	    }
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;	
	
	final String INPUT_FILE = "";
	final String OUTPUT_FILE = "";
	
	static Throwable throwable;

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		thread.run();
		if (Solution.throwable != null)
			throw Solution.throwable;
	}
	
	public void run() {
		try {
			if (INPUT_FILE.equals("")) {
				in = new BufferedReader(new InputStreamReader(System.in));
			} else {
				in = new BufferedReader(new FileReader(INPUT_FILE));
			}
			if (OUTPUT_FILE.equals("")) {
				out = new PrintWriter(System.out);
			} else {
				out = new PrintWriter(OUTPUT_FILE);
			}
			sc = new FastScanner(in);
			solve();
		} catch (Exception e) {
			throwable = e;
		} finally {
			out.close();
		}
	}

}

class FastScanner {
	
	BufferedReader reader;
	StringTokenizer strTok;
	
	FastScanner(BufferedReader reader) {
		this.reader = reader;
	}
	
	public String nextToken() throws Exception {
		while (strTok == null || !strTok.hasMoreTokens()) {
			strTok = new StringTokenizer(reader.readLine());
		}
		return strTok.nextToken();
	}
	
	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}
	
	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}
}