List
Time limit2sMemory limit1024 MB
Given n names, count for each length x the pairs whose length-x prefixes and length-x suffixes are both equal.
Problem
Scientists recently found a complete list of all worlds that existed before the first humans appeared on Earth. They want to collect some statistics from it, so they define when two names are similar.
Two names are called -similar if their suffixes of length are equal and their prefixes of length are equal.
The prefix of length of a string is its first characters. The suffix of length is its last characters. Taking a prefix or suffix longer than the string is an invalid operation.
For every integer from 1 to the maximum length of a name in the list, find the number of pairs of names that are -similar.
Input
The first line contains one integer (), the number of names. Each of the next lines contains one name. The total length of all names does not exceed . Every name consists of lowercase Latin letters and has non-zero length.
Output
On the first line, print , the length of the longest name. On the line for (), print the number of pairs of names that are -similar.