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

public class ECFRound9_C {
	public static void main(String[] args) throws IOException {
		Kattio io = new Kattio();

		int n = io.nextInt();
		String[] arr = new String[n];
		for (int i=0; i<n; i++) {
			String str = io.next();
			arr[i] = str;
		}
		Arrays.sort(arr, new CompString1());

		StringBuilder sb = new StringBuilder();

		for (String s : arr) {
			//System.out.println(s);
			sb.append(s);
		}
		io.println(sb);
		io.close();


	}

	static class CompString implements Comparator<String> {
		public int compare(String a, String b) {
			char[] chars1 = a.toCharArray();
			char[] chars2 = b.toCharArray();


			for (int i=0; i<Math.min(chars1.length, chars2.length); i++) {
				if (chars1[i] < chars2[i]) return -1;
				if (chars1[i] > chars2[i]) return 1;
			}

			//there is still chars left
			if (chars1.length > chars2.length) {
				for (int i=Math.min(chars1.length, chars2.length); i<Math.max(chars1.length, chars2.length); i++) {
					if (chars1[i] < chars2[0]) return -1;
					if (chars1[i] > chars2[0]) return 1; 
				}
			}

			if (chars1.length < chars2.length) {
				for (int i=Math.min(chars1.length, chars2.length); i<Math.max(chars1.length, chars2.length); i++) {
					if (chars2[i] < chars1[0]) return 1;
					if (chars2[i] > chars1[0]) return -1; 
				}
			}

			return 0;
		}
	}

	static class CompString1 implements Comparator<String> {
		public int compare(String a, String b) {
			return (a+b).compareTo(b+a);
		}
	}


	static class Kattio extends PrintWriter {
		private BufferedReader r;
		private StringTokenizer st;

		// standard input
		public Kattio() { this(System.in, System.out); }
		public Kattio(InputStream i, OutputStream o) {
			super(o);
			r = new BufferedReader(new InputStreamReader(i));
		}
		// USACO-style file input
		public Kattio(String problemName) throws IOException {
			super(new FileWriter(problemName + ".out"));
			r = new BufferedReader(new FileReader(problemName + ".in"));
		}

		// returns null if no more input
		public String next() {
			try {
				while (st == null || !st.hasMoreTokens())
					st = new StringTokenizer(r.readLine());
				return st.nextToken();
			} catch (Exception e) { }
			return null;
		}

		public int nextInt() { return Integer.parseInt(next()); }
		public double nextDouble() { return Double.parseDouble(next()); }
		public long nextLong() { return Long.parseLong(next()); }
	}
}