1685 - Next Permutation

Time Limit : 1 Second

Memory Limit : 512 MB

Submission: 61

Solved: 16

Description

Give you a permutation, tell us what is the next permutation.


If there is not next permutation. you should output "WTF!" (without quote)

Input

We have multiply cases. For each case:


The first line contains one number: N -- the length of the permutation (0 < N <= 1000)


The second line contains N number, Ai, representing the permutation (1 <= Ai <= N)

Output

For each case, output N integer in one line, the next permutation.

sample input
3
1 3 2
sample output
2 1 3
hint
source
© 2015 HUST ACMICPC TEAM. All Right Reserved.