Skip to main content
Back to problems
Codeforces
Easy
Strings
Simulation
Way Too Long Words

Shorten very long words by replacing the middle with the count of removed characters.

Acceptance 0%
Problem Statement

You are given a list of words. For each word, if its length is greater than 10, replace it with a shortened form consisting of its first letter, the number of omitted middle characters, and its last letter. Otherwise, keep the word unchanged.

For example, localization becomes l10n because 10 characters are removed from the middle.

Return the transformed words in the same order.

Input Format

Input

  • The first line contains an integer nn — the number of words.
  • The next nn lines each contain one non-empty word.

Interpretation

For each word:

  • if len(word) <= 10, output the word as-is;
  • otherwise output: first character + (len(word) - 2) + last character.

Output Format

Output

Print nn lines. Each line should contain the transformed version of the corresponding input word.

Constraints

  • 1n1001 \le n \le 100
  • Each word consists of lowercase English letters
  • The length of each word is at least 1 and at most 100
Examples
Sample cases returned by the problem API.

Example 1

Input

4
word
localization
internationalization
it

Output

word
l10n
i18n
it

Explanation

Only words longer than 10 characters are abbreviated. Short words stay unchanged.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.