Problem 2: Word List, (K Narayan Kumar, CMI)

In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (blank, newline).

Your task is print the words in the text in lexicographic order (that is, dictionary order). Each word should appear exactly once in your list. You can ignore the case (for instance, "The" and "the" are to be treated as the same word.) There should be no uppercase letters in the output.

For example, consider the following candidate for the input text:

This is a sample piece of text to illustrate this 
problem.

The corresponding output would read as:

a
illustrate
is
of
piece
problem
sample
text
this
to

Input format

The first line of input contains a single integer N, indicating the number of lines in the input. This is followed by N lines of input text.

Output format

The first line of output contains a single integer M indicating the number of distinct words in the given text. The next M lines list out these words in lexicographic order.

Test data

You may assume that N ≤ 10000 and that there are at most 80 characters in each line. You may also assume that there are at the most 1000 distinct words in the given text.

Example

We now illustrate the input and output formats using the above example.

Sample input

2
This is a sample piece of text to illustrate this 
problem.  

Sample output

10
a
illustrate
is
of
piece
problem
sample
text
this
to

CPU Timelimit: 3 seconds
Memory limit: 64M
Grading style: ioi
Register Now