import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int sum = 0; ArrayList> deques = new ArrayList<>(); for (int i = 0; i < N; i++) { deques.add(new ArrayDeque()); } for (int i = 0; i < N; i++) { char[] string = sc.next().toCharArray(); sum += string.length; for (int j = 0; j < string.length; j++) { deques.get(i).addLast(string[j]); } } sc.close(); StringBuilder sb = new StringBuilder(); while (sb.length() < sum) { int mini = 0; char minchar = 'z' + 1; for (int i = 0; i < deques.size(); i++) { if (deques.get(i).isEmpty()) { continue; } if (minchar > deques.get(i).peekFirst()) { mini = i; minchar = deques.get(i).peekFirst(); } } sb.append(deques.get(mini).pollFirst()); } System.out.println(sb.toString()); } }