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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int t = in.ni();
            for (int T = 0; T < t; T++) {
                int n = in.ni();
                List<Integer>[] g = new List[n];
                for (int i = 0; i < n; i++) {
                    g[i] = new ArrayList<>();
                }
                for (int i = 0; i < n - 1; i++) {
                    int a = in.ni() - 1;
                    int b = in.ni() - 1;
                    g[a].add(b);
                    g[b].add(a);
                }
                boolean[] mine = new boolean[n];
                int k1 = in.ni();
                int[] s1 = new int[k1];
                for (int i = 0; i < k1; i++) {
                    s1[i] = in.ni() - 1;
                    mine[s1[i]] = true;
                }
                int k2 = in.ni();
                int[] s2 = new int[k2];
                for (int i = 0; i < k2; i++) {
                    s2[i] = in.ni() - 1;
                }
                int ask = s2[0];
                out.println("B " + (ask + 1));
                out.flush();
                int resp = in.ni() - 1;
                if (mine[resp]) {
                    out.println("C " + (resp + 1));
                    out.flush();
                } else {
                    int[] queue = new int[n];
                    int qi = 1;
                    int v = queue[0] = resp;
                    int[] d = new int[n];
                    d[resp] = 1;
                    for (int i = 0; i < qi; i++) {
                        v = queue[i];
                        if (mine[v])
                            break;
                        if (d[v] > k2)
                            break;
                        for (int u : g[v]) {
                            if (d[u] == 0) {
                                queue[qi++] = u;
                                d[u] = d[v] + 1;
                            }
                        }
                    }
                    if (mine[v]) {
                        out.println("A " + (v + 1));
                        out.flush();
                        resp = in.ni() - 1;
                        boolean found = false;
                        for (int i = 0; i < k2; i++) {
                            if (s2[i] == resp) {
                                found = true;
                                break;
                            }
                        }
                        if (found) {
                            out.println("C " + (v + 1));
                            out.flush();
                        } else {
                            out.println("C -1");
                            out.flush();
                        }
                    } else {
                        out.println("C -1");
                        out.flush();
                    }
                }

            }


        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}

