#2974. Best Cow Line S

Best Cow Line S

Description

FJ带他的N头奶牛去参加比赛, 比赛前N头奶牛自觉的排好队, 每头奶牛以它自己名字的首字母给出. 但FJ对他们的顺序不满意,现在FJ想要把奶牛们重新排列,以达到他们的队列在字典顺序中最小. FJ的操作是这样的: 他打算把奶牛从旧队列中一个一个拉出来, 排到一个新队列去(刚开始新队列为空),他每次只能把旧队列目前剩下的第一位奶牛或最后一位奶牛拉出来, 排到新队列的最后一位去. He then proceeds to marshal the cows from the old line to the new one by repeatedly sending either the first or last cow in the (remainder of the) original line to the end of the new line. When he's finished, FJ takes his cows for registration in this new order.Given the initial order of his cows, determine the least lexicographic string of initials he can make this way.

Format

Input

第一行: 一个整数N , 1 <= N <= 2,000. 接下来有N行,每行一个大写字母: 'A'---'Z'. 这N行字母就是题目描述的奶牛们们自觉排好队的旧队列.

Output

每行输出80个字母, 最后一行若不够80个字母,则按实际个数输出.

Samples

6
A
C
D
B
C
B
ABCBCD

Limitation

说明: 6头牛的旧队列: ACDBCB 样例输出: ABCBCD