import java.util.*;
public class Main {
static void exists(int[] a,int[] b){
LinkedHashMap<Integer,String> c = new LinkedHashMap<Integer,String>();
for(int i=0;i<a.length;i++){
c.put(a[i]," ");
}
// System.out.println©;
for(int j=0;j<b.length;j++){
if(c.containsKey(b[j])){
// c.put(b[j],“Yes”);
System.out.println(“Yes”);
}
else{
System.out.println(“No”);
}
}
// for (Map.Entry<Integer, String> entry : c.entrySet()) {
// if(entry.getValue() == “Yes” || entry.getValue() == “No”)
// System.out.println(entry.getValue());
// }
// return “No”;
}
public static void main(String args[]) {
Main l = new Main();
Scanner sc = new Scanner(System.in);
long tc = sc.nextInt();
while(tc–>0){
int n = sc.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++){
a[i] = sc.nextInt();
}
int m = sc.nextInt();
int[] b = new int[m];
for(int j=0;j<m;j++){
b[j] = sc.nextInt();
}
l.exists(a,b);
}
}
}