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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CF_632C solver = new CF_632C();
        solver.solve(1, in, out);
        out.close();
    }

    static class CF_632C {
        int maxLen = 50;
        Comparator<Entry> cprt = (o1, o2) -> {
            String o12 = o1.s + o2.s;
            String o21 = o2.s + o1.s;
            return o12.compareTo(o21);
        };

        public void solve(int testNumber, InputReader input, PrintWriter out) {
            FastScanner in = new FastScanner(input);
            int n = in.i();
            Entry[] a = new Entry[n];
            for (int i = 0; i < n; ++i)
                a[i] = new Entry(in.s(), maxLen);

            Arrays.sort(a, cprt);

            StringBuilder sb = new StringBuilder();
            for (Entry ai : a)
                sb.append(ai.s);

            out.println(sb.toString());
        }

        class Entry {
            String s;

            Entry(String src, int padLen) {
                s = src;
//            char last = s.charAt(s.length() - 1);
//            StringBuilder sb = new StringBuilder(src);
//
//            int dif = padLen - s.length();
//            while(dif-- > 0)
//                sb.append(last);
//            padded = sb.toString();
            }

        }

    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
                catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }

    static class FastScanner {
        InputReader in;

        public FastScanner(InputReader in) {
            this.in = in;
        }

        public int i() {
            return in.nextInt();
        }

        public String s() {
            return in.next();
        }

    }
}