import java.util.*;

// Iroha's Strings
public class Main {
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // String params = scanner.nextLine();
        int numStrings = scanner.nextInt();
        int stringLen = scanner.nextInt(); 
        scanner.nextLine();
        // scanner.next() reads up until \n it won't consume it. You need next Line to pusition the 
        // System.out.println(scanner.nextLine()); // handle of first line \n that is

        List<String> strings = new ArrayList<>();
        for (int i=0; i<numStrings; i++) {
            String curr = scanner.nextLine();
            // System.out.println("curr" + curr);
            strings.add(curr);
        }
        // I have the strings now simply sort them and concatenate
        Collections.sort(strings);
        StringBuilder sb = new StringBuilder();
        for (String s : strings) {
            // System.out.printf("String:%s, numStrings:%d, stringLen:%d %n", s, numStrings, stringLen);
            sb.append(s);
        }                       
        scanner.close();            
        System.out.println(sb.toString());
    }
    
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz