This page is still under construction.

Parts of this page are still being built. What you see may change.

String Summarization

Interview

Time limit1sMemory limit512 MB

Summary
Given a string of sentences joined without spaces, shorten it to at most 25 characters using one of three fixed omission rules.
Level

Medium4 of 10

Topics
Implementation, String, Simulation, Greedy
Solved
No attempts yet

Problem

Standing tall on the high Namsan

(omitted)

Build it on a rock

The ground of Seonrin

You are given one or more sentences. Write a program that summarizes the sentences to at most 25 characters by omitting a middle portion according to the rules below.

For convenience of input and output, you are given instead a string SS formed by concatenating the sentences with no spaces. Think of the characters from the first character of the string up to the first '.' (period) as one sentence, and the characters from the character after each '.' up to the next '.' as another sentence. For example, if the given string SS is 'IamInevitable.IamIronMan.', then 'IamInevitable.' is one sentence and 'IamIronMan.' is another.

The rules are as follows.

  1. If the length of SS is at most 25, print SS as is.
  2. If the length of SS is greater than 25, consider the part of SS excluding the first 11 characters and the last 11 characters. If this remaining part lies entirely within the same sentence, omit it and replace it with '...' (three '.' characters), then print.
  3. If neither of the above cases applies, keep only the first 9 characters and the last 10 characters of SS, replace the middle with '......' (six '.' characters), and print.

Input

The first line gives the length NN of the string.

The second line gives a string SS consisting of NN characters.

Output

Summarize SS to at most 25 characters according to the rules given in the problem and print the result.

Constraints

2≤N≤100 0002 \leq N \leq 100\,000

The string SS consists only of uppercase letters, lowercase letters, commas (,), and periods (.).

The first character of SS is not a period (.).

The last character of SS is a period (.).

Hint

The ASCII codes for uppercase letters, lowercase letters, commas, and periods are 65-90, 97-122, 44, and 46, respectively.

Examples3

  1. Example 1

    Input
    11
    IamIronMan.
    
    Expected output
    IamIronMan.
    
  2. Example 2

    Input
    26
    And,IamIronMan.IamIronMan.
    
    Expected output
    And,IamIron...IamIronMan.
    
  3. Example 3

    Input
    29
    IamInevitable.And,IamIronMan.
    
    Expected output
    IamInevit......amIronMan.