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.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Queue;
import java.util.LinkedList;
import java.io.InputStream;

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

    static class TaskD {
        ArrayList<ArrayList<Integer>> list;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();

            while (t > 0) {
                int n = in.nextInt();
                list = in.initlist(n);
                for (int i = 0; i < n - 1; i++) {
                    int u = in.nextInt();
                    int v = in.nextInt();
                    list.get(u).add(v);
                    list.get(v).add(u);
                }
                int k1 = in.nextInt();
                int my[] = in.nextIntArray(k1);
                int k2 = in.nextInt();
                HashSet<Integer> hs = new HashSet<>();
                int lee[] = in.nextIntArray(k2);
                for (int i = 0; i < k2; i++) {
                    hs.add(lee[i]);
                }
                System.out.println("B" + " " + lee[0]);
                System.out.flush();
                int node = in.nextInt();
                //  System.out.println(node);
                int vis[] = new int[n + 1];
                int dis[] = new int[n + 1];
                vis[node] = 1;
                Queue<Integer> q = new LinkedList<>();
                q.add(node);
                while (q.size() != 0) {
                    int val = q.poll();
                    for (int x : list.get(val)) {
                        if (vis[x] == 0) {
                            dis[x] = 1 + dis[val];
                            vis[x] = 1;
                            q.add(x);
                        }
                    }
                }
                TreeSet<pair> tr = new TreeSet<>();
                for (int i = 0; i < k1; i++) {
                    tr.add(new pair(dis[my[i]], my[i]));
                }
                boolean find = false;
                int ct = 4;
                int answer = -1;
                for (pair x : tr) {
                    if (ct == 0) {
                        break;
                    }
                    System.out.println("A" + " " + x.ind);
                    System.out.flush();
                    int vall = in.nextInt();
                    if (hs.contains(vall)) {
                        answer = x.ind;
                        break;
                    }
                    ct--;
                }
                System.out.println("C" + " " + answer);
                System.out.flush();
                t--;
            }

        }

        class pair implements Comparable<pair> {
            int val;
            int ind;

            pair(int val, int ind) {
                this.val = val;
                this.ind = ind;
            }

            public int compareTo(pair o) {
                return this.val == o.val ? this.ind - o.ind : this.val - o.val;
            }

        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader(InputStream st) {
            this.stream = st;
        }

        public int read() {
            //*-*------clare------
//remeber while comparing 2 non primitive data type not to use ==
//remember Arrays.sort for primitive data has worst time case complexity of 0(n^2) bcoz it uses quick sort
//again silly mistakes ,yr kb tk krta rhega ye mistakes
//try to write simple codes ,break it into simple things
            // for test cases make sure println(); ;)
//knowledge>rating
        /*
        public class Main
        implements Runnable{
    public static void main(String[] args) {
        new Thread(null,new Main(),"Main",1<<26).start();

    }
    public void run() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();//chenge the name of task
        solver.solve(1, in, out);
        out.close();
    }
         */

            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public ArrayList<ArrayList<Integer>> initlist(int n) {
            ArrayList<ArrayList<Integer>> list = new ArrayList<>();
            for (int i = 0; i <= n; i++) {
                list.add(new ArrayList<Integer>());
            }
            return list;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

