// Arup Guha
// 12/26/2017
// Solution to 2017 Dec USACO Bronze Problem: The Bovine Shuffle

import java.util.*;
import java.io.*;

public class shuffle {

	public static void main(String[] args) throws Exception {

		// Read the grid.
		Scanner stdin = new Scanner(new File("shuffle.in"));

		// Read in perm backwards.
		int n = stdin.nextInt();
		int[] perm = new int[n];
		for (int i=0; i<n; i++) {
			int pos = stdin.nextInt();
			perm[i] = pos-1;
		}

		// How we want to shuffle the input.
		int[] finalperm = new int[n];
		for (int i=0; i<n; i++)
			finalperm[i] = perm[perm[perm[i]]];

		// Get ending cows.
		int[] ID = new int[n];
		for (int i=0; i<n; i++)
			ID[i] = stdin.nextInt();

		// Ta da!
		PrintWriter out = new PrintWriter(new FileWriter("shuffle.out"));
		for (int i=0; i<n; i++)
			out.println(ID[finalperm[i]]);
		out.close();
		stdin.close();
	}
}