import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class IntersectingSubtrees {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        for (int i = 0; i < t; i++) {
            int n = Integer.parseInt(br.readLine());
            Node[] graph = undirectedGraphFromEdgeList(br, n, n - 1);
            int k1 = Integer.parseInt(br.readLine());
            int[] meSubTree = Arrays.stream(br.readLine().split(" ")).mapToInt(x->Integer.parseInt(x)).toArray();
            Set<Integer> myNodes = new HashSet<>();
            for (int j = 0; j < meSubTree.length; j++) {
                myNodes.add(meSubTree[j]);
            }
            int k2 = Integer.parseInt(br.readLine());
            int[] liSubTree = Arrays.stream(br.readLine().split(" ")).mapToInt(x->Integer.parseInt(x)).toArray();
            Set<Integer> liNodes = new HashSet<>();
            for (int j = 0; j < liSubTree.length; j++) {
                liNodes.add(liSubTree[j]);
            }
            System.out.println("B " + liSubTree[0]);
            System.out.flush();
            int loc = Integer.parseInt(br.readLine());
            // find closest node to loc in your subtree
            Queue<Node> queue = new LinkedList<>();
            Set<Integer> seen = new HashSet<>();
            queue.add(graph[loc]);
            while(!queue.isEmpty()){
                Node nxt = queue.poll();
                if(myNodes.contains(nxt.ind)){
                    System.out.println("A " + nxt.ind);
                    System.out.flush();
                    int response = Integer.parseInt(br.readLine());
                    if(liNodes.contains(response)){
                        System.out.println("C " + nxt.ind);
                    }else{
                        System.out.println("C " + -1);
                    }
                    System.out.flush();
                    break;
                }else{
                    for(Node connect:nxt.edges){
                        if(!seen.contains(connect.ind)){
                            queue.add(connect);
                        }
                    }
                }
            }
        }
    }

    public static class Node {
        int ind = 0;
        Node[] edges;
    }

    /**
     * read an undirected graph in from br, from a list of it's edges.
     * Store the results as nodes with Node[] edges.
     * (Assumes edges are 1-indexed)
     */
    public static Node[] undirectedGraphFromEdgeList(BufferedReader br, int n, int m) throws IOException {
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }
        int[] counts = new int[n];
        int[][] edges = new int[m][2];
        for (int i = 0; i < m; i++) {
            String[] edge = br.readLine().split(" ");
            int a = Integer.parseInt(edge[0]) - 1;
            int b = Integer.parseInt(edge[1]) - 1;
            edges[i][0] = a;
            edges[i][1] = b;
            counts[a]++;
            counts[b]++;
        }
        for (int i = 0; i < n; i++) {
            nodes[i].edges = new Node[counts[i]];
        }
        for (int i = 0; i < edges.length; i++) {
            Node a = nodes[edges[i][0]];
            Node b = nodes[edges[i][1]];
            a.edges[a.ind++] = b;
            b.edges[b.ind++] = a;
        }
        return nodes;
    }

    /**
     * Return sorted 2D array of edges
     * (Assumes edges are 1-indexed)
     */
    public static int[][] adjList(BufferedReader br, int n, int m) throws IOException {
        n++;
        int[] counts = new int[n];
        int[][] edges = new int[m][2];
        for (int i = 0; i < m; i++) {
            String[] edge = br.readLine().split(" ");
            int a = Integer.parseInt(edge[0]);
            int b = Integer.parseInt(edge[1]);
            edges[i][0] = a;
            edges[i][1] = b;
            counts[a]++;
            counts[b]++;
        }
        int[][] adjList = new int[n][];
        for (int i = 0; i < n; i++) {
            adjList[i] = new int[counts[i]];
        }
        for (int i = 0; i < edges.length; i++) {
            adjList[edges[i][0]][--counts[edges[i][0]]] = edges[i][1];
            adjList[edges[i][1]][--counts[edges[i][1]]] = edges[i][0];
        }
        for (int i = 0; i < n; i++) {
            Arrays.sort(adjList[i]);
        }
        return adjList;
    }

}
