// Guide to Java
// Copyright 2014, by J.T. Streib and T. Soma


import java.util.*;
import java.io.*;

public class SortTerms {
 public static void main(String[] args) throws IOException {
     
    // declaration and initialization of variables
    String[] term;
    int i, numTerms;
    String fileName;
    Scanner scanner, inFile;
    PrintWriter outFile;
    
    // open input file
    inFile = new Scanner(new File("terms.txt"));

    // open output file
    outFile = new PrintWriter(new FileWriter("sortedTerms.txt"));

    // input number of strings
    numTerms = inFile.nextInt();
    term = new String[numTerms];

    // read words from file
    for(i=0; i<numTerms; i++)
       term[i] = inFile.next();

    // sort terms      
    Arrays.sort(term);
                        
    // output result to file
    for(i=0; i<numTerms; i++) {
       outFile.println(term[i]);
    }

    // close input file
    inFile.close();

    // close output file
    outFile.close();
 }
}