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.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.security.interfaces.DSAKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class a {

	public static class in {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(reader.readLine());
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}

	public static long comp(int n, int r) {
		r = Math.min(r, n - r);
		long ans = 1;
		for (int i = 1; i <= r; i++) {
			ans = ans * (long) (n - r + i) / (long) i;
		}
		return ans;

	}

	public static class node implements Comparable<node> {

		String a;

		node(String a) {
			this.a = a;

		}

		@Override
		public int compareTo(node o) {
			String s = o.a + a;
			String t = a + o.a;
			if (s.compareTo(t) > 0)
				return -1;
			else if(s.compareTo(t)<0)
				return 1;
			return 0;

		}
	}

	public static long gcd(int x, int y) {
		if (y == 0)
			return x;
		return gcd(y, x % y);
	}

	public static int z[];

	public static void Z_algorithm(char[] a, ArrayList<Long> arr) {
		z = new int[a.length];
		z[0] = a.length;
		int l = 0, r = 0;
		for (int i = 1; i < a.length; i++) {

			if (i > r) {
				l = r = i;

				while (r < a.length && a[r - l] == a[r]
						&& (long) arr.get(r - l) == (long) arr.get(r)) {

					r++;
				}

				z[i] = r - l;
				r--;
			} else {
				int k = i - l;
				if (z[k] < r - i + 1)
					z[i] = z[k];
				else {
					l = i;
					while (r < a.length && a[r - l] == a[r]
							&& (long) arr.get(r - l) == (long) arr.get(r))
						r++;
					z[i] = r - l;
					r--;
				}
			}

		}
	}

	public static long tree[];
	public static int n;

	public static void add(int idx, long val) {

		while (idx <= n) {
			tree[idx] += val;
			idx += (idx & -idx);
		}
	}

	public static long get(int idx) {
		long g = 0;
		while (idx > 0) {
			g += tree[idx];
			idx -= (idx & -idx);
		}
		return g;
	}

	public static void main(String[] args) throws IOException {
		StringBuilder qq = new StringBuilder();
		in.init(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// source code
		int x = in.nextInt();
		node a[] = new node[x];
		for (int i = 0; i < a.length; i++) {
			a[i] = new node(in.next());
		}
		Arrays.sort(a);
		for (int i = 0; i < a.length; i++) {
			out.print(a[i].a);
		}
		out.println();
		out.close();

	}
}