#P1283C. Friends and Gifts
Friends and Gifts
Description
There are friends who want to give gifts for the New Year to each other. Each friend should give exactly one gift and receive exactly one gift. The friend cannot give the gift to himself.
For each friend the value is known: it is either if the -th friend doesn't know whom he wants to give the gift to or if the -th friend wants to give the gift to the friend .
You want to fill in the unknown values () in such a way that each friend gives exactly one gift and receives exactly one gift and there is no friend who gives the gift to himself. It is guaranteed that the initial information isn't contradictory.
If there are several answers, you can print any.
The first line of the input contains one integer () — the number of friends.
The second line of the input contains integers (, , all are distinct), where is the either if the -th friend doesn't know whom he wants to give the gift to or if the -th friend wants to give the gift to the friend . It is also guaranteed that there is at least two values .
Print integers , where should be equal to if or the number of friend whom the -th friend wants to give the gift to. All values should be distinct, cannot be equal to . Each friend gives exactly one gift and receives exactly one gift and there is no friend who gives the gift to himself.
If there are several answers, you can print any.
Input
The first line of the input contains one integer () — the number of friends.
The second line of the input contains integers (, , all are distinct), where is the either if the -th friend doesn't know whom he wants to give the gift to or if the -th friend wants to give the gift to the friend . It is also guaranteed that there is at least two values .
Output
Print integers , where should be equal to if or the number of friend whom the -th friend wants to give the gift to. All values should be distinct, cannot be equal to . Each friend gives exactly one gift and receives exactly one gift and there is no friend who gives the gift to himself.
If there are several answers, you can print any.