import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Solution {
    static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
    static final int INf = 1_000_000_000;
    static FastReader reader;
    static PrintWriter writer;
    public static void main(String[] args) {
        Thread t = new Thread(null, new O(), "Integer.MAX_VALUE", 10000000);
        t.start();
    }
    static class O implements Runnable {
         public void run() {
            try {
                magic();
            }
            catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
            }
        }
    }
    static class FastReader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public FastReader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public FastReader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }
    //variables here
    static ArrayList<Integer> adj[];
    static int dis[];
    static void magic() throws IOException{
        reader = new FastReader();
        writer = new PrintWriter(System.out, true);
        int t = reader.nextInt();
        while(t-->0) {
            int n = reader.nextInt();
            adj = new ArrayList[n+1];
            for(int i=1;i<=n;++i) {
                adj[i] = new ArrayList<>();
            }
            for(int i=1;i<n;++i) {
                int u = reader.nextInt(), v = reader.nextInt();
                adj[u].add(v);
                adj[v].add(u);
            }
            int k1 = reader.nextInt();
            boolean inmysubtree[] = new boolean[n+1];
            HashSet<Integer> mysubtree = new HashSet<>();
            for(int i=0;i<k1;++i) {
                int x = reader.nextInt();
                inmysubtree[x] = true;
                mysubtree.add(x);
            }
            int k2 = reader.nextInt();
            int first = -1;
            boolean inuskasubtree[] = new boolean[n+1];
            HashSet<Integer> uskasubtree = new HashSet<>();
            for(int i=0;i<k2;++i) {
                int x = reader.nextInt();
                first = x;
                uskasubtree.add(x);
                inuskasubtree[x] = true;
            }
            int lol = queryB(first);
            if(inmysubtree[lol]) {
                writer.println("C "+lol);
            }
            else {
                dis = new int[n+1];
                dfs(lol,lol,0);
                int nearest = -1, min_dis = 78946546;
                for(int i=1;i<=n;++i) {
                    if(inmysubtree[i] && dis[i]<min_dis) {
                        min_dis = dis[i];
                        nearest = i;
                    }
                }
                int lul = queryA(nearest);
                if(inuskasubtree[lul]) {
                    writer.println("C "+nearest);
                }
                else {
                    writer.println("C -1");
                }
            }
        }
    }
    static void dfs(int x, int p, int l) {
        dis[x] = l;
        for(int e:adj[x]) {
            if(e!=p) {
                dfs(e, x, l+1);
            }
        }
    }
    static int queryA(int x) throws IOException{
        writer.println("A "+x);
        writer.flush();
        return reader.nextInt();
    }
    static int queryB(int y) throws IOException {
        writer.println("B "+y);
        writer.flush();
        return reader.nextInt();
    }
}