The Bovine Shuffle

Given a permutation describing one shuffle and the cow order after three shuffles, recover the original order before the shuffles.

Medium4ArrayImplementationSimulationMathInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Convinced that happy cows give 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 settled on the Bovine Shuffle. In the Bovine Shuffle his NN cows (1N1001 \le N \le 100) line up in a row in some order and then perform three shuffles in a row, after which they stand in a possibly different order. To make it easier for the cows to locate themselves, Farmer John numbered the spots in the line 11 through NN, so the first cow in the lineup stands at position 11, the next at position 22, and the last at position NN.

One shuffle is described by NN numbers a1,,aNa_1, \ldots, a_N. During the shuffle the cow at position ii moves to position aia_i, and every aia_i is between 11 and NN. Every cow moves to its assigned position during the shuffle. All of the aia_i are distinct, so no two cows ever try to move to the same position.

Each of Farmer John's cows carries a 7-digit integer ID, and no two cows share an ID. Given the order of the cows after the three shuffles, determine the order they started in.

Input

The first line contains NN, the number of cows. The second line contains the NN integers a1,,aNa_1, \ldots, a_N. The third line contains the order of the NN cows after three shuffles, with each cow given by its ID.

Output

Print NN lines giving the order of the cows before the three shuffles, one cow ID per line.