import java.util.*;
public class LastLetterSort {
	public static void main(String[] args) {
		Arrays.sort(args, new LastLetterComparator());
		for (int i = 0; i < args.length; i++) {
			System.out.println(args[i]);
		}
	}
}
