import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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 {
                Set<Integer> set1 = new HashSet<>();
                Set<Integer> set2 = new HashSet<>();
                boolean[] vis;

                public void solve(int testNumber, InputReader in, PrintWriter out) {
                        int n = in.i();
                        int[] from = new int[n];
                        int[] to = new int[n];
                        for (int i = 0; i < n - 1; i++) {
                                from[i] = in.i() - 1;
                                to[i] = in.i() - 1;
                        }
                        vis = new boolean[n];
                        Arrays.fill(vis, false);
                        int[][] graph = GraphUtil.UndirectedGraph(from, to, n);

                        int k = in.i();
                        for (int i = 0; i < k; i++) {
                                set1.add(in.i() - 1);
                        }

                        k = in.i();
                        for (int i = 0; i < k; i++) {
                                set2.add(in.i() - 1);
                        }

                        out.println("B " + 1);
                        out.flush();

                        int R = in.i() - 1;

                        int x = dfs(graph, R);

                        out.println("A " + (x + 1));
                        out.flush();

                        R = in.i() - 1;
                        if (set2.contains(R)) {
                                out.println("C " + (R + 1));
                                out.flush();
                        } else {
                                out.println("C -1");
                                out.flush();
                        }
                }

                private int dfs(int[][] graph, int r) {
                        vis[r] = true;
                        if (set1.contains(r)) {
                                return r;
                        }

                        int u = 0;

                        for (int x : graph[r]) {
                                if (!vis[x]) {
                                        vis[x] = true;
                                        u = dfs(graph, x);
                                }
                        }
                        return u;
                }

        }

        static class InputReader {
                InputStream is;
                private byte[] inbuf = new byte[1024];
                public int lenbuf = 0;
                public int ptrbuf = 0;

                public InputReader(InputStream is) {
                        this.is = is;
                }

                private int readByte() {
                        if (lenbuf == -1) throw new InputMismatchException();
                        if (ptrbuf >= lenbuf) {
                                ptrbuf = 0;
                                try {
                                        lenbuf = is.read(inbuf);
                                } catch (IOException e) {
                                        throw new InputMismatchException();
                                }
                                if (lenbuf <= 0) return -1;
                        }
                        return inbuf[ptrbuf++];
                }

                private boolean isSpaceChar(int c) {
                        return !(c >= 33 && c <= 126);
                }

                private int skip() {
                        int b;
                        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
                        return b;
                }

                public int i() {
                        int num = 0, b;
                        boolean minus = false;
                        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
                        if (b == '-') {
                                minus = true;
                                b = readByte();
                        }

                        while (true) {
                                if (b >= '0' && b <= '9') {
                                        num = num * 10 + (b - '0');
                                } else {
                                        return minus ? -num : num;
                                }
                                b = readByte();
                        }
                }

                public String next() {
                        int b = skip();
                        StringBuilder sb = new StringBuilder();
                        while (!(isSpaceChar(b))) {
                                sb.appendCodePoint(b);
                                b = readByte();
                        }
                        return sb.toString();
                }

        }

        static class GraphUtil {
                public static int[][] UndirectedGraph(int[] f, int[] t, int n) {
                        int[][] graph = new int[n][];
                        int[] p = new int[n];
                        for (int from : f) {
                                p[from]++;
                        }
                        for (int to : t) {
                                p[to]++;
                        }
                        for (int i = 0; i < n; i++) {
                                graph[i] = new int[p[i]];
                        }
                        for (int i = 0; i < f.length; i++) {
                                graph[f[i]][--p[f[i]]] = t[i];
                                graph[t[i]][--p[t[i]]] = f[i];
                        }
                        return graph;

                }

        }
}

