Each Christmas holidays, friends meet to celebrate a tradition. There are useless presents, which are called pongos. The pongos are wrapped up with newspaper, so at the beginning of the game the only available information for each pongo is : how cool seems while it is wrapped up. Let be the real coolness of . This real coolness is only known when the pongo is unwrapped. The higher the value of , the cooler the pongo looks when wrapped. The higher , the cooler it is when unwrapped.
The game goes as follows. The participants are numbered from 0 to . At the beginning of the -th round (from 0 to ), each of the first participants has an unwrapped pongo at his hands, which is seen by everybody. The round starts with the participant number . He always takes the pongo that looks or is coolest according to the available information: if the pongo is still unchosen and therefore wrapped up, he uses , and if the pongo is already on some participant’s hands, he uses .
If a participant takes a wrapped pongo, he unwraps it and the game goes to the next round. If he takes a pongo from another participant, the participant that just lost his pongo takes the pongo that is or looks coolest among those that have not been chosen in the current round. The round continues like this until someone takes a wrapped pongo and unwraps it.
This game is deterministic. Can you tell the real coolness of the pongo that every person has at the end of the game?
Input consists of several cases. Every case starts with , followed by the integers , followed by the integers . You can assume . All the values for and are distinct integers between and .
For every case, print the integers , where is the real coolness of the pongo at the hands of the -th person at the end of the game.
Input
3 1 0 2 5 4 3 6 3 9 7 1 2 11 10 4 6 5 8 0 5 0 1 2 3 4 9 8 7 6 5
Output
3 4 5 0 4 6 5 8 10 7 5 9 6 8