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

/**
 * Created by brechka on 2/26/2016.
 */
public class CF {
    public static void main(String[] args) {

        InputReader inputReader = new InputReader(System.in);
        PrintWriter printWriter = new PrintWriter(System.out, true);

        int n = inputReader.nextInt();
        StringToCompare[] a = new StringToCompare[n];
        for (int i = 0; i < n; i++) {
            a[i] = new StringToCompare(inputReader.next());
        }
        Arrays.sort(a);

        for (StringToCompare s : a) {
            printWriter.print(s.original);
        }

        printWriter.close();
    }

    private static class StringToCompare implements Comparable<StringToCompare>{
        private String original;

        public StringToCompare(String original) {
            this.original = original;
        }

        @Override
        public int compareTo(StringToCompare anotherString) {
            return this.original.concat(anotherString.original).compareTo(anotherString.original.concat(this.original));
        }
    }

    private static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public int[] nextIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextInt();
            }
            return array;
        }

        public long[] nextLongArray(int size) {
            long[] array = new long[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextLong();
            }
            return array;
        }

        public double[] nextDoubleArray(int size) {
            double[] array = new double[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextDouble();
            }
            return array;
        }

        public String[] nextStringArray(int size) {
            String[] array = new String[size];
            for (int i = 0; i < size; ++i) {
                array[i] = next();
            }
            return array;
        }

        public boolean[][] nextBooleanTable(int rows, int columns, char trueCharacter) {
            boolean[][] table = new boolean[rows][columns];
            for (int i = 0; i < rows; ++i) {
                String row = next();
                assert row.length() == columns;
                for (int j = 0; j < columns; ++j) {
                    table[i][j] = (row.charAt(j) == trueCharacter);
                }
            }
            return table;
        }

        public char[][] nextCharTable(int rows, int columns) {
            char[][] table = new char[rows][];
            for (int i = 0; i < rows; ++i) {
                table[i] = next().toCharArray();
                assert table[i].length == columns;
            }
            return table;
        }

        public int[][] nextIntTable(int rows, int columns) {
            int[][] table = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextInt();
                }
            }
            return table;
        }

        public long[][] nextLongTable(int rows, int columns) {
            long[][] table = new long[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextLong();
                }
            }
            return table;
        }

        public double[][] nextDoubleTable(int rows, int columns) {
            double[][] table = new double[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextDouble();
                }
            }
            return table;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = readLine();
                if (line == null) {
                    return false;
                }
                tokenizer = new StringTokenizer(line);
            }
            return true;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }
    }
}
