i18n

Time limit1sMemory limit128 MB

Problem

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.

  • An expansion is valid if the full word has appeared earlier in the text and its abbreviated form matches the abbreviation being expanded. Case is ignored when checking validity. For example, expanding 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).
  • An expansion is unambiguous if exactly one valid expansion exists. For example, l10n unambiguously expands to localization, but p5m cannot be expanded unambiguously, because both problem and program abbreviate to p5m.

Input

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.

  • A full word consists of 1 to 32 Latin letters and appears in one of three capitalization forms: all lowercase, First capital letter, or ALL CAPITAL LETTERS.
  • An abbreviated word consists of a Latin letter, followed by a number from 2 to 30 (without a leading zero), followed by a Latin letter. Abbreviated words use the three corresponding capitalization forms: all l7e, F3t C5l L4r, or ALL C5L L5S.

Output

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.