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 
    // Importing all important imports
     
    import java.awt.Point;
    import static java.lang.System.in;
    import java.io.BufferedReader;
    import java.io.ByteArrayInputStream;
    import java.io.DataInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintStream;
    import java.io.PrintWriter;
    import java.math.BigInteger;
    import java.math.BigDecimal;
    import java.math.MathContext;
    import java.math.RoundingMode;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.BitSet;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Hashtable;
    import java.util.InputMismatchException;
    import java.util.LinkedHashMap;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    import java.util.Stack;
    import java.util.Queue;
    import java.util.Random;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import java.util.Set;
    import java.util.SortedSet;
    import java.util.StringTokenizer;
    import java.util.TreeMap;
    import java.util.TreeSet;
    import java.util.Vector;
     
     
     
    /**
    @author
    * 
    $$\      $$\            $$$$$$\            
    $$$\    $$$ |          $$  __$$\           
    $$$$\  $$$$ | $$$$$$$\ $$ /  \__|  
    $$\$$\$$ $$ |$$  _____|$$$$\      
    $$ \$$$  $$ |\$$$$$$\  $$  _|     
    $$ |\$  /$$ | \____$$\ $$ |      
    $$ | \_/ $$ |$$$$$$$  |$$ |      
    \__|     \__|\_______/ \__|       
    *
    * @Mustafa Filmwala
    * @filmwalams@gmail.com
    * https://github.com/filmwalams/JAVA-Functions
    * 
    * 
    */
     
	public class Main{
            
            static boolean testcase=false;
            static boolean debug_mode=false;
            //static String input_file_name="";
            static String output_file_name="";
            
            //static String input_file_name="input.txt";
            //static String output_file_name="output.txt";
            
            public int mod=1000000007;
  
            public void solve(int tc) throws IOException
            {   
    			int n = ni();
    			long arr[][] = new long[n][3];

     			HashMap<Long,Integer> mp = new HashMap<Long,Integer>();
    			for(int i = 0;i<n;i++){
    				arr[i][0] = ni();
    				mp.put(arr[i][0],i);
    			}
    			ArrayList<TreeSet<Long>>  tree = new ArrayList<TreeSet<Long>>();
     			tree.add(new TreeSet<Long>());
     			tree.add(new TreeSet<Long>());
     			tree.add(new TreeSet<Long>());
     			tree.add(new TreeSet<Long>());

    			for(int i = 0;i<n;i++){
    				arr[i][1] = ni();
    				tree.get((int)arr[i][1]).add(arr[i][0]);
    			}
    			for(int i = 0;i<n;i++){
    				arr[i][2] = ni();
    				tree.get((int)arr[i][2]).add(arr[i][0]);
    			}
    			int m = ni();
    			for(int i = 0;i<m;i++){
    				int x = ni();

    				if(tree.get(x).isEmpty()){
    					out.print("-1 ");
    					continue;
    				}
    				int tshirtno = mp.get(tree.get(x).first());
    				int color1 = (int)arr[tshirtno][1];
    				int color2 = (int)arr[tshirtno][2];
    				long t = tree.get(x).first();
    				tree.get(color1).remove(t);
    				tree.get(color2).remove(t);
    				out.print(arr[tshirtno][0]+ " ");
    			}
    			out.println();
			}
            
     
            // END OF SOLUTION
            
            public void precompute(){}
            
            
            // INPUT OUTPUT TEMPLATE
            static String TESTCASES="";
            static PrintWriter out;
            static int Space;
            
            public static void main(String[] args) throws Exception{
                    // generateTestCases(1); 
                    long endTime,startTime=System.currentTimeMillis();
                    if(output_file_name.isEmpty())
    					out=new PrintWriter(new OutputStreamWriter(System.out));
                    else
    					out = new PrintWriter(new FileOutputStream("/home/filmwalams/Desktop/CONTEST/"+output_file_name));
                    //if(!input_file_name.isEmpty()){
    				//	mytestcases();
    				//}
                    InputStream myinp=TESTCASES.isEmpty() ? System.in : new ByteArrayInputStream(TESTCASES.getBytes());
                    init(myinp);
                    
                    Space=0;
                    Main program=new Main();
                    
                    program.precompute();
                    if(testcase==true){int test=ni();for(int tc=1;tc<=test;tc++)program.solve(tc);}
                    else program.solve(0);
                    
                    out.close();
                    endTime=System.currentTimeMillis();
                    //printTime("Time: "+(endTime-startTime)+"ms");
            }
            
            // Testcases reader from FILE. If file not found, input is taken from console.
            public static void mytestcases(){
    			
                try{
    				//TESTCASES=new String(Files.readAllBytes(Paths.get("/home/filmwalams/Desktop/CONTEST/"+input_file_name)));
                }
                catch(Exception e){
    				TESTCASES="";
    			}
            }
            
            public static void generateTestCases(int count){
    			
                PrintStream console=System.out;
                try{
    				PrintStream out = new PrintStream(new FileOutputStream("/home/filmwalams/Downloads"));
                
    				System.setOut(out);
    				Random r=new Random();
    				// System.out.println(count);
    				for(int tc=0;tc<count;tc++){
    					   
    				}
    				System.setOut(console);
                }
                catch(FileNotFoundException fe){
    				System.setOut(console);
    			}
            }
              
              
            // Just to print time, not to use anywhere else
            public static void printTime(Object ...obj){System.err.println(Arrays.deepToString(obj));}
            static InputStream is;
            static BufferedReader brr;
            protected static byte[] inbuf = new byte[1024];
            static int lbuffer = 0, pbuffer = 0;
            public static void init(InputStream input) {is=input;brr=new BufferedReader(new InputStreamReader(input));}
            // Fundamental
            protected static int rb(){if(lbuffer == -1)throw new InputMismatchException();if(pbuffer >= lbuffer){pbuffer = 0;try { lbuffer = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }if(lbuffer <= 0)return -1;}return inbuf[pbuffer++];}       
            protected static String line() throws IOException{return brr.readLine();}   
            protected static boolean isSpace(int c) { return !(c >= 33 && c <= 126); }
            protected static int skip(){ int b; while((b = rb()) != -1 && isSpace(b)); return b; }
            // Inputs
            protected static double nd() throws IOException { return Double.parseDouble(ns()); }
            protected static char nc() { return (char)skip(); }
            protected static String ns() throws IOException{if(Space==1)return line();int b = skip();StringBuilder sb = new StringBuilder();while(!(isSpace(b))){ sb.appendCodePoint(b);b = rb();}return sb.toString();}
            protected static char[] nca(int n){char[] buf = new char[n];int b = skip(), p = 0;while(p < n && !(isSpace(b))){buf[p++] = (char)b;b = rb();} return n == p ? buf : Arrays.copyOf(buf, p);}
            protected static int[] nia(int n) throws IOException{int[] a = new int[n];for(int i = 0;i < n;i++)a[i] = ni();return a;}
            protected static int[][] niaindex(int n) throws IOException{int ea[][]=new int[n][2];for(int i=0;i<n;i++){ea[i][0]=ni();ea[i][1]=i;}return ea;}
            protected static long[] nla(int n) throws IOException{long[] a = new long[n];for(int i = 0;i < n;i++)a[i] = nl();return a;}
            protected static long[][] nlaindex(int n) throws IOException{long ea[][]=new long[n][2];for(int i=0;i<n;i++){ea[i][0]=ni();ea[i][1]=i;}return ea;}
            protected static String[] nsa(int n) throws IOException{String[] a = new String[n];for(int i = 0;i < n;i++)a[i] = ns();return a;    }
            protected static double[] nda(int n) throws IOException{double[] a = new double[n];for(int i = 0;i < n;i++)a[i] = nd();return a;}
            protected static int ni() throws IOException{if(Space==1)return Integer.parseInt(line());int num=0,b;boolean minus = false;while((b = rb())!= -1 && !((b>='0'&&b<='9') || b =='-'));if(b =='-'){minus=true;b = rb();    }while(true){if(b >= '0' && b <= '9'){num = num * 10 + (b - '0');}else{return minus ? -num : num;}b = rb();}}  
            protected static long nl() throws IOException{if(Space==1)return Long.parseLong(line());long num = 0;int b;boolean minus = false;while((b = rb()) != -1 && !((b >= '0' && b <= '9') || b == '-'));if(b == '-'){   minus = true;b = rb();}while(true){if(b >= '0' && b <= '9'){num = num * 10 + (b - '0');}else{return minus ? -num : num;}b = rb();}}
            // Outputs
            public static void pln(){out.println();}
            public static void ps(String s){out.print(s);}
            public static void pi(int s){out.print(s);}
            public static void pl(long s){out.print(s);}
            public static void pd(double s){out.print(s);}
            public static void psp(){out.print(" ");}
            public static void parr(int s[]){out.println(Arrays.toString(s));}
            public static void parr(String s[]){out.println(Arrays.toString(s));}
            public static void parr(long s[]){out.println(Arrays.toString(s));}        
            public static void parr2(int s[][]){for(int i=0;i<s.length;i++)out.println(Arrays.toString(s[i]));}
            public static void parr2(long s[][]){for(int i=0;i<s.length;i++)out.println(Arrays.toString(s[i]));}
            public static void parr2(String s[][]){for(int i=0;i<s.length;i++)out.println(Arrays.toString(s[i]));}
            
            
    }   
     