import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}

} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	} main {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int l = in.nextInt(); l in.nextInt() in.nextInt in ArrayList<String> list = new ArrayList<>(); list new ArrayList<>() for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		} int i =0; int i =0; i 0 i<n i n i++ i++ i {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		} {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		} String s = in.next(); s in.next() in.next in if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			} s.length()==l && s.equals(s.toLowerCase()) s.length()==l s.length() s.length s l s.equals(s.toLowerCase()) s.equals s s.toLowerCase() s.toLowerCase s {
				list.add(s);
			} list.add(s) list.add list s Collections.sort(list) Collections.sort Collections list for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		} int i =0 ; int i =0 ; i 0 i<list.size() i list.size() list.size list i++ i++ i {
			System.out.print(list.get(i));
		} {
			System.out.print(list.get(i));
		} System.out.print(list.get(i)) System.out.print System.out System System.out list.get(i) list.get list i System.out.println() System.out.println System.out System System.out String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}

} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		ArrayList<String> list = new ArrayList<>();
		for (int i =0;i<n;i++) {
			String s = in.next();
			if (s.length()==l && s.equals(s.toLowerCase())) {
				list.add(s);
			}
		}
		Collections.sort(list);
		
		
		
		for (int i =0 ;i<list.size(); i++) {
			System.out.print(list.get(i));
		}
		System.out.println();
	}

}
