1. Erste Version: Java, Evgeni Pavlidis


/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 0.580
* @author Evgeni Pavlidis evgenipavlidis@yahoo.de
*/
import java.util.*;
import java.io.*;

class Main extends Thread {

private Scanner input = new Scanner(System.in);
private List<String> list = new ArrayList<String>();
private List<String> floats = new ArrayList<String>();
private Map<Integer,Integer> permutation = new HashMap<Integer,Integer>();


public static void main(String... args)
{
(new Main()).start();
}

public void run()
{
int cycles = input.useDelimiter("\n").nextInt();

for(int i = 1; i <= cycles; i++)
{
input.useDelimiter("\n").next();
if(i != 1)
System.out.println();
list.clear();
permutation.clear();
floats.clear();

readPermutation(input.useDelimiter("\n").next());
input.nextLine();
readFloats(input.useDelimiter("\n").next());
rearrange();

printList();
}

System.exit(0);
}

void readPermutation(String s)
{
Scanner scanner = new Scanner(s);
int c = 1;
while(scanner.hasNextInt())
permutation.put(scanner.nextInt(), c++);
}

void readFloats(String s)
{
Scanner scanner = new Scanner(s);
while(scanner.hasNext())
floats.add(scanner.next());
}

void rearrange()
{
for(int i =1; i <= permutation.size(); i++)
{
list.add(floats.get(permutation.get(i)-1));
}
}

void printList()
{
for(String d: list)
System.out.println(d);
}
}