# Sequence

Time Limit: 5000MS

Memory Limit: 65536K

## Description

Given a sequence, {*A*_{1}, *A*_{2}, ..., *A*_{n}} which is guaranteed *A*_{1 }> *A*_{2}, ..., *A*_{n}, you are to cut it into three sub-sequences and reverse them separately to form a new one which is the smallest possible sequence in alphabet order. The alphabet order is defined as follows: for two sequence {*A*_{1}, *A*_{2}, ..., *A*_{n}} and {*B*_{1}, *B*_{2}, ..., *B*_{n}}, we say {*A*_{1}, *A*_{2}, ..., *A*_{n}} is smaller than {*B*_{1}, *B*_{2}, ..., *B*_{n}} if and only if there exists such *i* ( 1 ≤ *i* ≤ *n*) so that we have *A*_{i} < *B*_{i and }A_{j} = *B*_{j} for each *j* < *i*.

## Output

output *n* lines which is the smallest possible sequence obtained.

## Hint

{10, 1, 2, 3, 4} -> {10, 1 | 2 | 3, 4} -> {1, 10, 2, 4, 3}

## Source

POJ Founder Monthly Contest – 2008.04.13, Yao