import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

/**
 * Created by timur on 28.03.15.
 */

public class TaskD {
    boolean eof;
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

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

    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return "-1";
            }
        }
        return st.nextToken();
    }

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

    public long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }


    void run() throws IOException {
        InputStream input = System.in;
        PrintStream output = System.out;
        try {
            File f = new File("ab.in");
            if (f.exists() && f.canRead()) {
                input = new FileInputStream(f);
                output = new PrintStream("a.out");
            }
        } catch (Throwable e) {
        }
        br = new BufferedReader(new InputStreamReader(input));
        out = new PrintWriter(output);
        solve();
        br.close();
        out.close();
    }

    long gcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return gcd(b, a % b);
    }

    int[] p;
    boolean[] c;

    ArrayList<Integer>[] ed;

    void dfs(int v) {
        int u;
        for (int i = 0; i < ed[v].size(); i++) {
            u = ed[v].get(i);
            if (u != p[v]) {
                p[u] = v;
                dfs(u);
            }
        }
    }

    int up(int v) {
        if (c[v])
            return v;
        else
            return up(p[v]);
    }

    void solve() {
        int t = nextInt();
        for (int i = 0; i < t; i++) {
            int n = nextInt();
            p = new int[n];
            for (int j = 0; j < n; j++) {
                p[j] = -1;
            }

            c = new boolean[n];
            ed = new ArrayList[n];
            for (int j = 0; j < n; j++) {
                ed[j] = new ArrayList<>();
            }
            int o, p;
            for (int j = 0; j < n - 1; j++) {
                o = nextInt() - 1;
                p = nextInt() - 1;
                ed[o].add(p);
                ed[p].add(o);
            }
            int x = 0;
            int k1 = nextInt();
            for (int j = 0; j < k1; j++) {
                x = nextInt() - 1;
                c[x] = true;
            }
            dfs(x);
            TreeSet<Integer> v = new TreeSet<>();
            int k2 = nextInt();
            for (int j = 0; j < k2; j++) {
                v.add(nextInt() - 1);
            }

            x = v.first();
            out.println("B " + (x + 1));
            out.flush();
            int ans = nextInt() - 1;
            int q = up(ans);
            out.println("A " + (q + 1));
            out.flush();
            int qa = nextInt() - 1;
            if (v.contains(qa)) {
                out.println("C " + (q + 1));
            } else {
                out.println("C -1");
            }
            out.flush();

        }
    }

}