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

public class D4 {

    public BufferedReader input;
    public PrintWriter output;
    public StringTokenizer stoken = new StringTokenizer("");

    public static void main(String[] args) throws IOException {
        new D4();
    }

    D4() throws IOException {
        input = new BufferedReader(new InputStreamReader(System.in));
        output = new PrintWriter(System.out);
        run();
        input.close();
        output.close();
    }

    private void run() throws IOException {
        long t = nextLong();
        for (int i = 0; i < t; i++) {
            long n = nextLong();
            ArrayList<ArrayList> m = new ArrayList<>();
            for (int j = 0; j < n; j++) {
                m.add(new ArrayList());
            }
            for (int j = 0; j < n - 1; j++) {
                long a = nextLong() - 1;
                long b = nextLong() - 1;
                m.get((int) a).add((int) b);
                m.get((int) b).add((int) a);
            }
            long k = nextLong();
            boolean[] isinY = new boolean[(int) n];
            for (int j = 0; j < k; j++) {
                isinY[Math.toIntExact(nextLong() - 1)] = true;
            }
            long k2 = nextLong();
            boolean[] isinH = new boolean[(int) n];
            long f = nextLong() - 1;
            isinH[(int) f] = true;
            for (int j = 1; j < k2; j++) {
                isinH[Math.toIntExact(nextLong() - 1)] = true;
            }
            System.out.println("B " + (f + 1));
            long ans = nextLong() - 1;
            if (isinY[(int) ans]) {
                System.out.println("C " + (ans + 1));
                continue;
            } else {
                boolean[] was = new boolean[(int) n];
                long us = dfs((int) ans, m, isinY, was);
                System.out.println("A " + (us + 1));
                long their = nextLong() - 1;
                if (isinH[(int) their]) {
                    System.out.println("C " + (us + 1));
                } else {
                    System.out.println("C -1");
                }
            }
        }
    }

    private long dfs(int pos, ArrayList<ArrayList> m, boolean[] isinY, boolean[] was) {
        if (isinY[pos]) {
            return pos;
        }
        was[pos] = true;
        for (int i = 0; i < m.get(pos).size(); i++) {
            if (!was[(int) m.get(pos).get(i)]) {
                long r = dfs((int) m.get(pos).get(i), m, isinY, was);
                if (r >= 0) {
                    return r;
                }
            }
        }
        return -10;
    }

    private Long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextString());
    }

    private String nextString() throws IOException {
        while (!stoken.hasMoreTokens()) {
            String st = input.readLine();
            stoken = new StringTokenizer(st);
        }
        return stoken.nextToken();
    }
}