import java.util.ArrayList;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class lyftp4{

    private static InputReader sc;
    private static PrintWriter pw;

    private static ArrayList<ArrayList<Integer>> tree;
    private static int isPart[];

    private static void solve(){
        int n = sc.nextInt();
        isPart = new int[n+1];

        tree = new ArrayList<>();

        for(int i=0; i<=n; i++)
            tree.add(new ArrayList<>());

        for(int i=0; i<n-1; i++){
            int a = sc.nextInt(), b = sc.nextInt();
            tree.get(a).add(b);
            tree.get(b).add(a);
        }
        //System.out.println("Tree input complete.");

        int k1 = sc.nextInt();
        for(int i=0; i<k1; i++) {
            int in = sc.nextInt();
            isPart[in] = 1;
        }

        int k2 = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();

        for(int i=0; i<k2; i++){
            int in = sc.nextInt();
            set.add(in);
        }

        int element = set.iterator().next();
        System.out.println("B "+element);
        System.out.flush();

        element = sc.nextInt();

        int queue[] = new int[n], visited[] = new int[n+1], front = 0, rear = -1, q = 0;
        queue[++rear] = element;
        visited[element] = 1;

        while(rear >= front){
            q = queue[front++];

            if(isPart[q] == 1)
                break;

            for(Integer p: tree.get(q)){
                if(visited[p] == 0){
                    visited[p] = 1;
                    queue[++rear] = p;
                }
            }
        }

        System.out.println("A "+q);
        System.out.flush();

        int res = sc.nextInt();
        if(set.contains(res))
            System.out.println("C "+q);
        else
            System.out.println("C -1");
    }

    public static void main(String args[]) {
        sc = new InputReader(System.in);
        pw = new PrintWriter(System.out);

        int t = sc.nextInt();
        while(t-->0)
            solve();

        pw.flush();
        pw.close();
    }

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

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

        int snext() {
            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++];
        }

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

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

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

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

        boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        public interface SpaceCharFilter {
            boolean isSpaceChar(int ch);
        }
    }
}