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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {

	/**
	 * @param args
	 */
	static class Node
	{
		Node suffLink;
		Node prev;
		int dpst=0;
		int len;
		int sum=0;
		int []ach=new int[11];
		HashMap<Character,Node> links;
		public Node (int l)
		{
			suffLink=null;
			links=new HashMap<Character,Node>();
			len=l;
		}
		
	}
	static Node begin,last,dummy;
	static void addChar(char a)
	{
		
		Node p=last;
		Node nn=new Node(p.len+1);
		if(a>='0'&& a<='9')
		{
			for(int i=0; i<10; i++)
				nn.ach[i]=1;
			nn.ach[a-'0']=2;
		}
		
		while(!p.links.containsKey(a))
		{
			p.links.put(a, nn);
			p=p.suffLink;
		}
		Node q=p.links.get(a);
		if(q==begin)
		{
			nn.suffLink=q;
		}
		else
		{
			if(q.len==p.len+1)
			{
				nn.suffLink=q;
			}
			else
			{
				Node cl=new Node(q.len+1);
				cl.suffLink=q.suffLink;
				cl.links.putAll(q.links);
				nn.suffLink=cl;
				q.suffLink=cl;
				
				while(p!=dummy)
				{
					
					if(p.links.containsKey(a)&&p.links.get(a)==q)
						p.links.put(a, cl);
					p=p.suffLink;
				}
				
			}
		}
		last=nn;
	}
	static HashSet<Node> marked;
	static void printAut(Node q)
	{
		Queue<Node> ord=new LinkedList<Node>();
		ord.add(q);
		HashSet<Node> us=new HashSet<Node>();
		us.add(q);
		while(ord.size()!=0)
		{
			Node v=ord.poll();
		pw.println("-=-----");
		pw.println(v);
		pw.println("sufflink to "+v.suffLink );
		pw.print("achivable ");
		for(int i=0; i<10; i++)
			pw.print(v.ach[i]+" ");
		pw.println();
		for(Character c:v.links.keySet())
		{
			pw.println("by" + c + "to "+v.links.get(c));
			if(!us.contains(v.links.get(c)))
			{
				us.add(v.links.get(c));
				ord.add(v.links.get(c));
			}
		}
		pw.flush();
		}
	}
	static void mark(Node v, char c)
	{
		boolean ok=false;
		pw.println(v+" "+ (int) c);
		for(Character cc: v.links.keySet())
		{
			if(v.links.get(cc).ach[c-'0']==0)
			{
				v.links.get(cc).ach[c-'0']=-1;
				mark(v.links.get(cc),c);
			}
			if(v.links.get(cc).ach[c-'0']==2)
			{
				ok=true;
				
			}
		}
		if(ok)
			v.ach[c-'0']=2;
		else
			v.ach[c-'0']=1;
		//return false;
	}
	
	static int N;
	static void mark(Node v)
	{
		boolean ok=false;
	//	pw.println(v+" ");
		for(Character cc: v.links.keySet())
		{
			if(v.links.get(cc).ach[0]==0)
			{
				mark(v.links.get(cc));
		
			}
		
			
		}
		
		for(Character cc: v.links.keySet())	
		for(int i=0; i<N; i++)
				{
				v.ach[i]=Math.max(v.ach[i], v.links.get(cc).ach[i]);
			//	v.sum+=v.ach[i];
				}
		for(int i=0; i<N; i++)
		{
		v.sum+=v.ach[i];
		}
		
	}
	
	
	static StringBuffer rss=new StringBuffer();
	static StringBuffer sb=new StringBuffer();
	static int CNT(int[]c,int n)
	{
		int r=0;
		for(int i=0; i<n; i++)
			r+=c[i];
		return r;
	}
	static Node lst=begin;
	static int n2;
	static HashSet<Node>us=new HashSet<Node>();
	static void  getString(Node v, int n,Node prv)
	{
		us.add(v);
		if(v.dpst<prv.dpst+1)
		{
		v.prev=prv;
		v.dpst=v.prev.dpst+1;
		}
		if(v.dpst>lst.dpst)
			lst=v;
		for(Character c:v.links.keySet())
		{
			if(v.links.get(c).sum==n2&&!us.contains(v.links.get(c)))
			{
				//sb.append(c);
				getString(v.links.get(c),n,v);
				//sb.deleteCharAt(sb.length()-1);
			}
			
		}
		
		
		//return sb.toString();
	}
	static char[] retStr()
	{
		char rs[]=new char[lst.dpst];
		while(lst.len!=0)
		{
			for(Character c:lst.prev.links.keySet())
				if(lst.prev.links.get(c)==lst)
					{
						rs[lst.dpst-1]=c;
						lst=lst.prev;
						break;
					}
		}
		return rs;
	}
	static BufferedReader bf;
	static PrintWriter pw;
	static public class myStr implements Comparable <myStr>
	{
		String s;
		public myStr(String t)
		{
			s=t;
		}
		@Override
		public int compareTo(myStr a) {
			// TODO Auto-generated method stub
			
			return s.concat(a.s).compareTo(a.s.concat(s));
		}
		
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
	 bf=new BufferedReader(new InputStreamReader(System.in));
	    pw=new PrintWriter(System.out);
	
	//BufferedReader bf=new BufferedReader(new FileReader("substr3.in"));
		//PrintWriter pw=new PrintWriter("substr3.out");
	
		
	StringTokenizer stk=new StringTokenizer(bf.readLine());
	int n=Integer.parseInt(stk.nextToken());	
	ArrayList<myStr> p=new ArrayList<myStr>();
	int mxL=0;
	for(int i=0; i<n; i++)
	{
		String s=bf.readLine();//.concat(String.valueOf((char)('z'+4)));
		if(s.length()>mxL)
			mxL=s.length();
		p.add(new myStr(s));
	}
	//for(int i=0; i<p.size(); i++)
//	{
	//	myStr g=p.get(i);
	//	for(int j=g.s.length(); j<mxL; j++)
		//	g.s=g.s.concat(String.valueOf(g.s.charAt(g.s.length()-1)).toUpperCase());
	//	p.remove(i);
		//p.add(i, g);
	//}
	Collections.sort(p);
	for(myStr s:p)
	{
		for(int j=0; j<s.s.length(); j++)
			if(s.s.charAt(j)>92) pw.print(s.s.charAt(j));
			else
				break;
	}
	//pw.println(mxB);
	pw.close();
	}
	
}

/*


3
abacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacaba
mycabarchivemycabarchivemycabarchiveabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacaba
acabistrueacabistrueacabistrueabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacabaabacaba

3
abacaba
mycabarchive
acabistrue

3
aba
aba
bab
*/