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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class C {

	static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer tok = new StringTokenizer("");

	public static void main(String[] args) throws IOException {
		int N = readInt();
		String[] S = new String[N];
		for (int i=0; i<N; i++) {
			S[i] = readString();
		}
		Arrays.sort(S, new Comparator<String>() {

			@Override
			public int compare(String o1, String o2) {
				int n1 = o1.length();
				int n2 = o2.length();
				for (int i=0; i<n1&&i<n2; i++) {
					if (o1.charAt(i)<o2.charAt(i)) return -1;
					if (o1.charAt(i)>o2.charAt(i)) return 1;
				}
				if (n1==n2) return 0;
				if (n1<n2) return compare(o1, o2.substring(n1));
				return compare(o1.substring(n2), o2);
			}
		});
		System.out.println(String.join("", S));
	}

	static String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " .");
		}
		return tok.nextToken();
	}

	static int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	static long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	static int[] readArr(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = readInt();
		}
		return res;
	}

	static long[] readArrL(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = readLong();
		}
		return res;
	}

	static void readArr2(int[] A, int[] B) throws IOException {
		int n = A.length;
		for (int i = 0; i < n; i++) {
			A[i] = readInt();
			B[i] = readInt();
		}
	}

	static void readArrL2(long[] A, long[] B) throws IOException {
		int n = A.length;
		for (int i = 0; i < n; i++) {
			A[i] = readLong();
			B[i] = readLong();
		}
	}
}