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.util.Arrays;
import java.util.Scanner;

public class C {
	
	static class Str implements Comparable<Str> {
		String s;
		
		public Str(String s) {
			this.s = s;
		}
		
		public int compareTo(Str that) {
			for (int i = 0; ; i++) {
				if (i == this.s.length()) {
					if (i == that.s.length()) {
						return 0;
					} else {
						return  this.compareTo(new Str(that.s.substring(i)));
					}
				} else if (i == that.s.length()) {
					return -that.compareTo(new Str(this.s.substring(i)));
				} else if (this.s.charAt(i) != that.s.charAt(i)) {
					return this.s.charAt(i) - that.s.charAt(i);
				}
			}
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Str[] s = new Str[n];
		for (int i = 0; i < s.length; i++) {
			s[i] = new Str(in.next());
		}
		Arrays.sort(s);
		for (int i = 0; i < s.length; i++) {
			System.out.print(s[i].s);
		}
	}

}