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 int x[],y[], par[],lev[];
    static boolean usme_hai[];
    static ArrayList<Integer> adj[];
    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<>();
            }
            x = new int[n];
            y = new int[n];
            for(int i=1;i<n;++i) {
                int u = reader.nextInt(), v = reader.nextInt();
                x[i] = u;
                y[i] = v;
                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();
            boolean inuskasubtree[] = new boolean[n+1];
            HashSet<Integer> uskasubtree = new HashSet<>();
            for(int i=0;i<k2;++i) {
                int x = reader.nextInt();
                uskasubtree.add(x);
                inuskasubtree[x] = true;
            }
            if(k1<=5) {
                boolean found = false;
                for(int e:mysubtree) {
                    int lol = queryA(e);
                    if(inuskasubtree[lol]) {
                        writer.println("C "+e);
                        writer.flush();
                        found = true;
                        break;
                    }
                }
                if(!found) {
                    writer.println("C -1");
                    writer.flush();
                }
            }
            else if(k2<=5) {
                boolean found = false;
                for(int e:uskasubtree) {
                    int lol = queryB(e);
                    if(inmysubtree[lol]) {
                        writer.println("C "+lol);
                        writer.flush();
                        found = true;
                        break;
                    }
                }
                if(!found) {
                    writer.println("C -1");
                    writer.flush();
                }
            }
            else {
                ArrayList<Integer> list = new ArrayList<>();
                for(int e:uskasubtree) {
                    list.add(e);
                }
                ArrayList<Integer> uska_corr = new ArrayList<>();
                randomShuffle(list, 100000);
                HashSet<Integer> asked = new HashSet<>();
                boolean found = false;
                for(int i=0;i<5;++i) {
                    while(true) {
                        int index = (int)(random()*list.size());
                        int ele = list.get(index);
                        if(!asked.contains(ele)) {
                            int corr = queryB(ele);
                            if(inmysubtree[corr]) {
                                writer.println("C "+corr);
                                writer.flush();
                                found = true;
                            }
                            else {
                                uska_corr.add(corr);
                            }
                            asked.add(ele);
                            break;
                        }
                    }
                    if(found) {
                        break;
                    }
                }
                if(!found) {
                    par = new int[n+1];
                    lev = new int[n+1];
                    dfs(1,0,1);
                    usme_hai = new boolean[n+1];
                    for(int i=1;i<5;++i) {
                        mark(uska_corr.get(0), uska_corr.get(i));
                    }
                    for(int i=1;i<=n;++i) {
                        if(usme_hai[i] && inmysubtree[i]) {
                            found = true;
                            writer.println("C "+i);
                            writer.flush();
                            break;
                        }
                    }
                    if(!found) {
                        writer.println("C -1");
                        writer.flush();
                    }
                }
            }
        }
    }
    static void mark(int a, int b) {
        int lca = lca(a,b);
        while(a!=lca) {
            usme_hai[a] = true;
            a = par[a];
        }
        while(b!=lca) {
            usme_hai[b] = true;
            b = par[b];
        }
        usme_hai[lca] = true;
    }
    static int lca(int a, int b) {
        if(lev[a]>lev[b]) {
            int temp = a;
            a = b;
            b = temp;
        }
        while(lev[b]!=lev[a]) {
            b = par[b];
        }
        if(a==b) {
            return a;
        }
        while(par[a]!=par[b]) {
            a = par[a];
            b = par[b];
        }
        return par[a];
    }
    static void dfs(int x, int p, int l) {
        par[x] = p;
        lev[x] = l;
        for(int e:adj[x]) {
            if(e!=p) {
                dfs(e,x,l+1);
            }
        }
    }
    static ArrayList<Integer> randomShuffle(ArrayList<Integer> list,int nswaps) {
        int n = list.size();
        int arr[] = new int[n];
        for(int i=0;i<n;++i) {
            arr[i] = list.get(i);
        }
        for(int i=0;i<nswaps;++i) {
            int x = (int)(random()*n);
            int y = (int)(random()*n);
            int temp = arr[x];
            arr[x] = arr[y];
            arr[y] = temp;
        }
        ArrayList<Integer> newlist = new ArrayList<>();
        for(int o : arr) {
            newlist.add(o);
        }
        return newlist;
    }
    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();
    }
}