import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.ArrayDeque;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Liavontsi Brechka
 */
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);
        DPeresekayushiesyaPodderevya solver = new DPeresekayushiesyaPodderevya();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPeresekayushiesyaPodderevya {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            main:
            while (t-- > 0) {
                int n = in.nextInt();
                ArrayList<Integer>[] adj = new ArrayList[n];
                for (int i = 0; i < n; i++) {
                    adj[i] = new ArrayList<>();
                }

                for (int i = 0; i < n - 1; i++) {
                    int u = in.nextInt() - 1;
                    int v = in.nextInt() - 1;
                    adj[u].add(v);
                    adj[v].add(u);
                }

                int k1 = in.nextInt();
                HashSet<Integer> my = new HashSet<>(k1);
                for (int i = 0; i < k1; i++) {
                    my.add(in.nextInt());
                }

                int k2 = in.nextInt();
                int[] his = new int[k2];
                for (int i = 0; i < k2; i++) {
                    his[i] = in.nextInt();
                }

                out.println("B " + his[0]);
                out.flush();

                int root = in.nextInt() - 1;

                if (my.contains(root)) {
                    out.println("C " + root);
                    out.flush();
                } else {
                    ArrayDeque<Integer> queue = new ArrayDeque<>();
                    boolean[] isVisited = new boolean[n];

                    isVisited[root] = true;
                    queue.offer(root);

                    while (!queue.isEmpty()) {
                        Integer u = queue.poll();
                        for (Integer v : adj[u]) {
                            if (!isVisited[v]) {
                                isVisited[v] = true;
                                if (my.contains(v)) {
                                    out.println("A " + v);
                                    out.flush();

                                    int check = in.nextInt() - 1;

                                    for (int i = 0; i < k2; i++) {
                                        if (his[i] == check) {
                                            out.println("C " + v);
                                            out.flush();
                                            continue main;
                                        }
                                    }

                                    out.println("C -1");
                                    out.flush();
                                    continue main;
                                } else {
                                    queue.offer(v);
                                }
                            }
                        }
                    }
                }
            }
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

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

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}

