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


public class Main {  
    public static void main(String[] args) { 
        InputStream inputStream = System.in;  
        OutputStream outputStream = System.out;  
        Scanner in = new Scanner(inputStream);  
        PrintWriter out = new PrintWriter(outputStream);  
        solve(in, out);  
        out.close();  
    }  
    	
    static int n;
    static String[] a;
    
    static int go(String sx, String sy) {
    	String x = sx + sy;
    	String y = sy + sx;
    	return x.compareTo(y);
    }
    
    static class Comp implements Comparator {
    	public int compare(Object x, Object y) {
    		return go(x.toString(), y.toString());
    	}
    }
    
    static void solve(Scanner in, PrintWriter out) {  
    	n = in.nextInt();
    	a = new String[n];
    	for(int i = 0; i < n; i ++) a[i] = in.next();
    	Arrays.sort(a, 0, n, new Comp());
    	for(int i = 0; i < n; i ++) 
    		out.printf(a[i]);
    	out.flush();
    }  

    static class pii implements Comparable<pii> {  
        int X, Y;  
        pii(int X, int Y) {  
            this.X = X;  
            this.Y = Y;  
        }  
        public int compareTo(pii a) {  
            if(this.X - a.X != 0) return this.X - a.X;  
            else return this.Y - a.Y;  
        }  
    }  
    
    static class Scanner {    
        BufferedReader br;    
        StringTokenizer st;    
                
        public Scanner(InputStream in) {  
            br = new BufferedReader(new InputStreamReader(in));  
            eat("");  
        }   
          
        private void eat(String s) {    
            st = new StringTokenizer(s);  
        }    
        
        public String nextLine() {    
            try {    
                return br.readLine();    
            } catch (IOException e) {    
                return null;    
            }    
        }    
        
        public boolean hasNext() {    
            while (!st.hasMoreTokens()) {    
                String s = nextLine();    
                if (s == null)    
                return false;    
                eat(s);    
            }    
            return true;    
        }    
        
        public String next() {    
            hasNext();    
            return st.nextToken();    
        }    
        
        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());    
        }    
            
    }    
}