import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Wolfgang Beyer
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskD {
        int n;
        Node[] nodes;
        List<Integer> mySub;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            nodes = new Node[n + 1];
            for (int i = 0; i <= n; i++) nodes[i] = new Node();
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                nodes[a].addNeighbor(b);
                nodes[b].addNeighbor(a);

            }
            int k1 = in.nextInt();
            mySub = new ArrayList();
            for (int i = 0; i < k1; i++) {
                mySub.add(in.nextInt());
            }

            int k2 = in.nextInt();
            List<Integer> otherSub = new ArrayList();
            for (int i = 0; i < k2; i++) {
                otherSub.add(in.nextInt());
            }

            out.println("B " + otherSub.get(0));
            out.flush();
            int anchor = in.nextInt();
            if (anchor == -1) return;

            boolean[] visited = new boolean[n];
            int closest = bfs(anchor);

            out.println("A " + closest);
            out.flush();
            int closestTrans = in.nextInt();
            if (closestTrans == -1) return;

            if (otherSub.contains(closestTrans)) {
                out.println("C " + closest);
            } else {
                out.println("C -1");
            }
            out.flush();
        }

        int bfs(int root) {
            boolean[] visited = new boolean[n + 1];
            Queue<Integer> q = new LinkedList<>();
            q.add(root);
            visited[root] = true;

            while (!q.isEmpty()) {
                int node = q.poll();
                if (mySub.contains(node)) {
                    return node;
                }
                for (int neighbor : nodes[node].neighbors) {
                    if (!visited[neighbor]) {
                        q.add(neighbor);
                        visited[neighbor] = true;
                    }
                }
            }
            return -1;
        }

        class Node {
            List<Integer> neighbors;

            public Node() {
                neighbors = new ArrayList();
            }

            void addNeighbor(int x) {
                neighbors.add(x);
            }

        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

        public InputReader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                    //tok = new StringTokenizer(in.readLine(), ", \t\n\r\f"); //adds commas as delimeter
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}

