/*
Keep solving problems. 
*/

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

public class Interactive {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    int[] dx = {0, -1, 0, 1};
    int[] dy = {1, 0, -1, 0};

    int T;
    int n;
    List<List<Integer>> graph;
    Set<Integer> set1;
    Set<Integer> set2;
    void solve() throws IOException {
        T = nextInt();
        for (int i = 0; i < T; i++) {
            n = nextInt();
            graph = new ArrayList<>();
            for (int j = 0; j < n; j++) {
                graph.add(new ArrayList<>());
            }

            set1 = new HashSet<>();
            set2 = new HashSet<>();
            for (int j = 0; j < n - 1; j++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                graph.get(u).add(v);
                graph.get(v).add(u);
            }

            int k1 = nextInt();
            for (int j = 0; j < k1; j++) {
                set1.add(nextInt() - 1);
            }
            int k2 = nextInt();
            for (int j = 0; j < k2; j++) {
                set2.add(nextInt() - 1);
            }

            for (int b : set2) {
                outln("B " + (b + 1));
                break;
            }

            int r = nextInt() - 1;
            int nxt = findMin(r);
            outln("A " + (nxt + 1));
            int q = nextInt() - 1;
            if (set2.contains(q)) {
                outln("C " + (r + 1));
            }
            else {
                outln("c " + (-1));
            }
        }
    }

    int findMin(int target) {
        int[] dist = new int[n];
        Arrays.fill(dist, Integer.MAX_VALUE);
        Deque<Integer> deque = new LinkedList<>();
        deque.add(target);
        dist[target] = 0;
        while (!deque.isEmpty()) {
            int cur = deque.removeFirst();
            for (int nxt : graph.get(cur)) {
                if (dist[nxt] > 1 + dist[cur]) {
                    dist[nxt] = 1 + dist[cur];
                    deque.add(nxt);
                }
            }
        }

        int res = -1;
        int max = Integer.MAX_VALUE;
        for (int v : set1) {
            if (dist[v] < max) {
                res = v;
                max = dist[v];
            }
        }

        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }
    private void outln(Object o) {
        out.println(o);
        out.flush();
    }
    private void out(Object o) {
        out.print(o);
        out.flush();
    }
    public Interactive() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Interactive();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}
