A badly placed word

Write a program that, given an almost sorted sequence of words with exactly one word that appears too soon, prints the sequence totally sorted.

Input

Input consists of two or more words made up only of lowercase letters. All the words are different. The sequence is alphabetically sorted except for a word that appears too soon. The end of input is marked with the special word “END”.

Output

Print the sequence totally sorted.

Observation

In this problem, you should not use vectors, lists, or alike.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:00:41.684Z

© Jutge.org, 2006–2026.
https://jutge.org