Convinced that happy cows produce more milk, Farmer John has installed a giant disco ball in his barn and plans to teach his cows to dance!
After looking up popular cow dances, Farmer John decides to teach his cows the "Bovine Shuffle". The Bovine Shuffle consists of cows lining up in a row in some order and then performing three "shuffles" in succession, after which they may be arranged in a different order. To make it easier for his cows to find their positions, Farmer John labels the locations in the row with positions 1, \ldots, n. Thus, the first cow in the lineup occupies position , the next cow occupies position , and so on, up to position .
A shuffle is described by numbers, a_1, \ldots, a_n, where the cow in position moves to position a_i during the shuffle. Each a_i is in the range 1, \ldots, n. Every cow moves to a new position during the shuffle. Fortunately, all the a_i values are distinct, so no two cows try to move to the same position.
Each of Farmer John's cows has a distinct -digit integer ID number. Given the ordering of the cows after three shuffles, determine their initial ordering.
The first line contains n~(1 \le n \le 100), the number of cows. The next line contains integers a_1, \ldots, a_n, describing the shuffle. The final line contains the order of the cows after three shuffles, with each cow represented by its ID number.
Print lines, each containing a single cow ID, specifying the order of the cows before the three shuffles.
Beispiel 1