#K45517. Formatted Name

    ID: 27771 Type: Default 1000ms 256MiB

Formatted Name

Formatted Name

You are given a full name as a string. The name may contain extra spaces and can include a first name, one or more middle names, and a last name.

Your task is to format the name such that the output consists of the last name, a comma, the first name, and then the initial of each middle name (if any). If there are no middle names, simply output the last name and the first name.

For example:

  • Input: John Jacob Jingleheimer Schmidt → Output: Schmidt, John J J
  • Input: Mary Elizabeth Morrison → Output: Morrison, Mary E
  • Input: Alex Turner → Output: Turner, Alex
  • Input: Clara Anne Bell → Output: Bell, Clara A
  • Input: robert downey junior → Output: junior, robert d

The names should be output exactly as they appear (i.e. without altering case, aside from removing extra spaces).

inputFormat

The input will consist of a single line read from stdin, containing the full name which might include extra spaces.

outputFormat

The output should be a single line printed to stdout containing the formatted name.

## sample
John Jacob Jingleheimer Schmidt
Schmidt, John J J