import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int n = kb.nextInt();
String[] arr = new String[n];
StringBuilder sb = new StringBuilder();
for(int i=0; i<n; i++) {
arr[i] = kb.next();
}
Arrays.sort(arr, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
// 사전순
if(o1.length()== o2.length()) {
return o1.compareTo(o2);
}else {
// 길이 짧은 순
return o1.length()- o2.length();
}
}
});
sb.append(arr[0]).append('\n');
for(int i=1; i<n; i++) {
if(!arr[i-1].equals(arr[i])) {
sb.append(arr[i]).append('\n');
}
}
System.out.println(sb.toString());
}
}