Internationalization and localization are long words that are commonly abbreviated as i18n and l10n. The number between the first and last letters is the count of letters that were omitted. This is a powerful abbreviation scheme that can be applied naturally to any word.
A word may be abbreviated only if it has already appeared earlier in the text. To abbreviate a word, keep only its first and last letters and replace every letter in between with the count of omitted letters.
Your task is to write a program that expands such abbreviations in a given text wherever possible. An abbreviation can be expanded only if the expansion is both valid and unambiguous.
i18n to internationalization is valid (even if internationalization previously appeared only with a capital I). Expanding p14n to parameterization is not valid, because parameterization never appeared before the abbreviation. Expanding a11n to abbreviation is not valid, because a11n is not the correct abbreviation of abbreviation (the correct one is a10n).l10n unambiguously expands to localization, but p5m cannot be expanded unambiguously, because both problem and program abbreviate to p5m.The input contains at most 1000 lines, each with at most 80 characters. Each line contains one or more words separated by spaces and the special symbols -, ,, ., ", (, ), :, ;, !, ?. There are no trailing spaces, but a line may end with one of the other separators.
Each word is either full or abbreviated.
l7e, F3t C5l L4r, or ALL C5L L5S.Reproduce the original text with its original separators, expanding abbreviated words into full words wherever possible (as described above). The capitalization of an expanded word must match the capitalization of the abbreviation it replaces.
Leave invalid or ambiguous abbreviations unchanged (still abbreviated). Note that lines in the output may be longer than 80 characters.