import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int M = sc.nextInt();
            int[] arr = new int[M];
            for(int i = 0; i < M; i++) {
                String s = sc.next();
                int len = s.length();
                arr[i] = Integer.parseInt(
                    s.substring(len - 6, len)
                );
            }
            Arrays.sort(arr);
            for(int i = 0; i < M; i++) {
                System.out.println(arr[i]);
            }
        }
    }
}