import java.io.*;
import java.math.*;
import java.util.*;

public class IntersectingSubtrees {
    public static void solve(FastIO io) {
        int T = io.nextInt();

        while (T-- > 0) {
            int N = io.nextInt();

            Node[] nodes = new Node[N + 1];
            for (int i = 1; i <= N; ++i) {
                nodes[i] = new Node(i);
            }

            for (int i = 1; i < N; ++i) {
                int A = io.nextInt();
                int B = io.nextInt();

                nodes[A].next.add(nodes[B]);
                nodes[B].next.add(nodes[A]);
            }

            int K1 = io.nextInt();

            for (int i = 0; i < K1; ++i) {
                int X = io.nextInt();

                nodes[X].subtree = true;
            }

            int K2 = io.nextInt();

            HashSet<Integer> Y = new HashSet<>();
            int y0 = -1;
            for (int i = 0; i < K2; ++i) {
                int Yi = io.nextInt();

                Y.add(Yi);
                y0 = Yi;
            }

            // System.out.println("HERE");

            io.printf("B %d\n", y0);
            io.flush();

            // System.out.printf("waiting for xRoot...\n");
            // System.out.flush();

            int xRoot = io.nextInt();

            // System.out.printf("got xRoot = %d\n", xRoot);
            // System.out.flush();

            if (nodes[xRoot].subtree) {
                io.printf("C %d\n", xRoot);
                io.flush();
                continue;
            }

            root(nodes[xRoot], null);

            Node subRoot;
            for (int i = 1;; ++i) {
                if (nodes[i].subtree && nodes[i].parent != null && !nodes[i].parent.subtree) {
                    subRoot = nodes[i];
                    break;
                }
            }

            io.printf("A %d\n", subRoot.id);
            io.flush();

            int yNode = io.nextInt();

            if (Y.contains(yNode)) {
                io.printf("C %d\n", subRoot.id);
            } else {
                io.println("C -1");
            }
            io.flush();
        }
    }

    private static void root(Node u, Node p) {
        u.parent = p;
        u.next.remove(p);
        for (Node v : u.next) {
            root(v, u);
        }
    }

    private static final class Node {
        public int id;
        public boolean subtree;

        public HashSet<Node> next = new HashSet<>();
        public Node parent;

        public Node(int i) {
            this.id = i;
        }
    }

    public static class FastIO {
        private InputStream reader;
        private PrintWriter writer;

        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastIO(InputStream r, OutputStream w) {
            reader = r;
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(w)));
        }

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

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            return nextIntArray(n, 0);
        }

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

        public long[] nextLongArray(int n) {
            return nextLongArray(n, 0);
        }

        public long[] nextLongArray(int n, int off) {
            long[] arr = new long[n + off];
            for (int i = 0; i < n; i++) {
                arr[i + off] = nextLong();
            }
            return arr;
        }

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

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void printArray(int[] arr) {
            for (int i = 0; i < arr.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(arr[i]);
            }
        }

        public void printArray(long[] arr) {
            for (int i = 0; i < arr.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(arr[i]);
            }
        }

        public void printlnArray(int[] arr) {
            printArray(arr);
            writer.println();
        }

        public void printlnArray(long[] arr) {
            printArray(arr);
            writer.println();
        }

        public void printf(String format, Object... args) {
            print(String.format(format, args));
        }

        public void flush() {
            writer.flush();
        }
    }

    public static void main(String[] args) {
        FastIO io = new FastIO(System.in, System.out);
        solve(io);
        io.flush();
    }
}
