A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers pi, ai and bi, where pi is the price of the i-th t-shirt, ai is front color of the i-th t-shirt and bi is back color of the i-th t-shirt. All values pi are distinct, and values ai and bi are integers from 1 to 3.

m buyers will come to the shop. Each of them wants to buy exactly one t-shirt. For the j-th buyer we know his favorite color cj.

A buyer agrees to buy a t-shirt, if at least one side (front or back) is painted in his favorite color. Among all t-shirts that have colors acceptable to this buyer he will choose the cheapest one. If there are no such t-shirts, the buyer won't buy anything. Assume that the buyers come one by one, and each buyer is served only after the previous one is served.

You are to compute the prices each buyer will pay for t-shirts.

Input

The first line contains single integer n (1 ≤ n ≤ 200 000) — the number of t-shirts.

The following line contains sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ 1 000 000 000), where pi equals to the price of the i-th t-shirt.

The following line contains sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 3), where ai equals to the front color of the i-th t-shirt.

The following line contains sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 3), where bi equals to the back color of the i-th t-shirt.

The next line contains single integer m (1 ≤ m ≤ 200 000) — the number of buyers. 

The following line contains sequence c1, c2, ..., cm (1 ≤ cj ≤ 3), where cj equals to the favorite color of the j-th buyer. The buyers will come to the shop in the order they are given in the input. Each buyer is served only after the previous one is served.

Output

Print to the first line m integers — the j-th integer should be equal to the price of the t-shirt which the j-th buyer will buy. If the j-th buyer won't buy anything, print -1.

Examples

Input

5
300 200 400 500 911
1 2 1 2 3
2 1 3 2 1
6
2 3 1 2 1 1


Output

200 400 300 500 911 -1 


Input

2
1000000000 1
1 1
1 2
2
2 1


Output

1 1000000000 
import java.io.*;
import java.util.*;

public class Pattern {

  private static final String REGEX = " ";
  private static final Boolean DEBUG = false;
  private static final String FILE_NAME = "input.txt";



  public static void main(String[] args) throws IOException {
    Solver solver = new Solver();
    solver.readData();
    solver.solveAndPrint();
  }

  private static class Solver {

    int n, m;
    int[] p, a, b, c;

    public void readData() throws IOException {
      InputStream in = DEBUG ? new FileInputStream(FILE_NAME) : System.in;
      Scanner scanner = new Scanner(in);
      n = scanner.nextInt();
      scanner.nextLine();
      p = splitInteger(scanner.nextLine(), n);
      a = splitInteger(scanner.nextLine(), n);
      b = splitInteger(scanner.nextLine(), n);
      m = scanner.nextInt();
      scanner.nextLine();
      c = splitInteger(scanner.nextLine(), m);
    }

    public void solveAndPrint() {
      boolean[] tShirt = new boolean[n];

      Map<Integer, Set<Integer>> colorToTShirt = new HashMap<>();
      Map<Integer, Iterator<Integer>> colorToIterator = new HashMap<>();

      for (int i = 0; i < n; i++) {
        if (!colorToTShirt.containsKey(a[i])) {
          colorToTShirt.put(a[i], new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
              if (p[o1]==p[o2]){
                return 1;
              }
              return p[o1] - p[o2];
            }
          }));
        }
        Set<Integer> set = colorToTShirt.get(a[i]);
        set.add(i);
      }
      for (int i = 0; i < n; i++) {
        if (!colorToTShirt.containsKey(b[i])) {
          colorToTShirt.put(b[i], new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
              if (p[o1]==p[o2]){
                return 1;
              }
              return p[o1] - p[o2];
            }
          }));
        }
        Set<Integer> set = colorToTShirt.get(b[i]);
        set.add(i);
      }
      for (Integer integer : colorToTShirt.keySet()) {
        colorToIterator.put(integer, colorToTShirt.get(integer).iterator());
      }

      StringBuilder builder = new StringBuilder();
      for (int i = 0; i < m; i++) {
        int color = c[i];
        if (!colorToTShirt.containsKey(color)) {
          builder.append(-1);
          if (i != m - 1) {
            builder.append(" ");
          }
          continue;
        }
        Iterator<Integer> iterator = colorToIterator.get(color);

        Integer next = -1;
        boolean wasFound = false;
        while (iterator.hasNext()) {
          next = iterator.next();
          if (!tShirt[next]){
            tShirt[next] = true;
            wasFound = true;
            break;
          }
        }

        if (!wasFound) {
          builder.append(-1);
          if (i != m - 1) {
            builder.append(" ");
          }
          continue;
        } else {
          builder.append(p[next]);
          if (i != m - 1) {
            builder.append(" ");
          }
        }
      }


      System.out.print(builder);
    }

    public int[] splitInteger(String string, int n) {
      final String[] split = string.split(REGEX, n);
      int[] result = new int[n];
      for (int i = 0; i < n; ++i) {
        result[i] = Integer.parseInt(split[i]);
      }
      return result;
    }
    public int[] splitInteger(String string) {
      return splitInteger(string, 0);
    }


    public long[] splitLong(String string, int n) {
      final String[] split = string.split(REGEX, n);
      long[] result = new long[n];
      for (int i = 0; i < n; ++i) {
        result[i] = Long.parseLong(split[i]);
      }
      return result;
    }

    public long[] splitLong(String string) {
      return splitLong(string, 0);
    }
    public double[] splitDouble(String string, int n) {
      final String[] split = string.split(REGEX, n);
      double[] result = new double[n];
      for (int i = 0; i < n; ++i) {
        result[i] = Double.parseDouble(split[i]);
      }
      return result;
    }

    public double[] splitDouble(String string) {
      return splitDouble(string, 0);
    }

    public String[] splitString(String string, int n) {
      return string.split(REGEX, n);
    }

    public String[] splitString(String string) {
      return splitString(string, 0);
    }

    public int max(int a, int b){
      return Math.max(a, b);
    }

    public long max(long a, long b){
      return Math.max(a, b);
    }

    public int min(int a, int b){
      return Math.min(a, b);
    }

    public long min(long a, long b){
      return Math.min(a, b);
    }

    public double max(double a, double b){
      return Math.max(a, b);
    }

    public double min(double a, double b){
      return Math.min(a, b);
    }

  }



}
