#K93817. Lexicographically Minimal Timetable
Lexicographically Minimal Timetable
Lexicographically Minimal Timetable
You are given an even integer \( n \), a list of \( n \) train names, and a separator character. Your task is to create a timetable by first sorting the train names in lexicographical order. Then, for every two consecutive names in the sorted list, form two possible strings by concatenating the pair with the separator in both orders. Out of these two, choose the lexicographically smaller one and add it to the timetable.
Finally, sort the resulting timetable entries lexicographically and output them. This problem tests your ability to manipulate strings and perform sorting operations.
inputFormat
The input consists of three lines:
- The first line contains an even integer \( n \) indicating the number of trains.
- The second line contains \( n \) train names separated by spaces.
- The third line contains a single character that represents the separator.
outputFormat
Output \( \frac{n}{2} \) lines. Each line should contain one timetable entry. The timetable entries should be printed in lexicographical order.
## sample4
express bullet freight cargo
.
bullet.cargo
express.freight
</p>