import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Collection;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStream;

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

    static class DIntersectingSubtrees {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            ArrayList<Integer>[] adj;
            Set<Integer> mine = new HashSet<>();
            Set<Integer> theirs = new HashSet<>();
            for (int i = 0; i < t; i++) {
                mine.clear();
                theirs.clear();
                int n = in.nextInt();
                adj = new ArrayList[n + 1];
                for (int a = 0; a < n + 1; a++) adj[a] = new ArrayList<>();
                for (int a = 0; a < n - 1; a++) {
                    int c = in.nextInt();
                    int d = in.nextInt();
                    adj[c].add(d);
                    adj[d].add(c);
                }
                int k1 = in.nextInt();
                for (int a = 0; a < k1; a++) {
                    mine.add(in.nextInt());
                }
                int k2 = in.nextInt();
                for (int a = 0; a < k2; a++) {
                    theirs.add(in.nextInt());
                }
                out.println("B " + theirs.iterator().next());
                out.flush();
                int start = in.nextInt();
                if (mine.contains(start)) {
                    out.println("C " + start);
                } else {
                    Queue<Integer> q = new LinkedList<>();
                    Set<Integer> visited = new HashSet<>();
                    int res = 0;
                    q.add(start);
                    while (!q.isEmpty()) {
                        int c = q.poll();
                        visited.add(c);
                        if (mine.contains(c)) {
                            res = c;
                            break;
                        }
                        for (Integer a : adj[c]) if (!visited.contains(a)) q.add(a);
                    }
                    out.println("A " + res);
                    out.flush();
                    int c = in.nextInt();
                    if (theirs.contains(c)) {
                        out.println("C " + res);
                    } else {
                        out.println("-1");
                    }
                }
                out.flush();
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

