cho.sh
Notes
Loading...

Word Sorting

Time limit

2s

Memory limit

256 MB

Problem

You are given N lowercase English words. Remove duplicate words, then sort the remaining words by the following rules.

  1. A shorter word comes first.
  2. If two words have the same length, the lexicographically smaller word comes first.

Input

The first line contains the number of words N. (1 ≤ N ≤ 20,000)

Each of the next N lines contains one lowercase English word. The length of each word is at most 50.

Output

Print the unique words in the required order, one word per line.