// Arup Guha
// 11/14/2015
// Solution to 2015 SER D2 Problem: Xedni Drawkcab

import java.util.*;

public class xedni {

	public static void main(String[] args) {

		// Read in input and reverse it.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		String[] words = new String[n];
		for (int i=0; i<n; i++)
			words[i] = reverse(stdin.next());

		// Sort and output.
		Arrays.sort(words);
		for (int i=0; i<n; i++)
			System.out.println(words[i]);
	}

	// Returns the reverse of s.
	public static String reverse(String s) {
		char[] res = new char[s.length()];
		for (int i=0; i<s.length(); i++)
			res[i] = s.charAt(s.length()-1-i);
		return new String(res);
	}
}
