Letter Sequence Analysis

Time limit1sMemory limit128 MB

Problem

Cryptographic analysis relies heavily on how often individual letters and letter sequences appear in a language. For English text, for example, knowing that E, L, N, R, S, and T are among the most common letters — and knowing the most common letter pairs, triplets, and so on — reveals a great deal about an encrypted message.

Write a program that reads a block of text and performs letter-sequence analysis on it. For every sequence length from 1 to 5, report the sequences that occur with the five highest frequencies: the single characters with the five highest frequencies, the character pairs with the five highest frequencies, and so on up to sequences of five characters.

Only consider contiguous runs of alphabetic characters, and ignore case (so a and A are the same letter). A sequence of length $L$ is any run of $L$ consecutive letters that lies entirely within one such alphabetic run; a sequence never crosses a non-letter character.

Input

The input is a single block of text of arbitrary length that may span several lines. Read it until end of file. It may contain letters, digits, punctuation, and whitespace.

Output

Print one section for each sequence length from 1 to 5. Each section starts with the header line

Analysis for Letter Sequences of Length L

followed by a line of dashes (-) as long as the header (41 dashes). Then, for that length, print the frequencies in descending order, using at most the five highest distinct frequencies. For each such frequency print

Frequency = F, Sequence(s) = (S1,S2,...)

where S1, S2, … are all sequences that occur exactly $F$ times, written in upper case, separated by commas with no spaces, and listed in alphabetical order. If a length has fewer than five distinct frequencies, print only as many as exist (possibly none). Separate consecutive length sections with a single blank line.