import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class D1075 {

	static int N, K1, K2, init;
	static ArrayList<Integer>[] adj;
	static HashSet<Integer> mine, his;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		Scanner fs = new Scanner(System.in);
		int T = fs.nextInt();

		cases: for (int t = 1; t <= T; t++) {
			N = fs.nextInt();
			adj = new ArrayList[N + 1];
			for (int i = 0; i <= N; i++)
				adj[i] = new ArrayList<>();
			for (int i = 1; i < N; i++) {
				int u = fs.nextInt(), v = fs.nextInt();
				adj[u].add(v);
				adj[v].add(u);
			}
			K1 = fs.nextInt();
			mine = new HashSet<>();
			for (int i = 0; i < K1; i++)
				mine.add(fs.nextInt());
			K2 = fs.nextInt();
			his = new HashSet<>();
			for (int i = 0; i < K2; i++)
				his.add(init = fs.nextInt());
			int root = queryB(init, fs);
			boolean[] vis = new boolean[N + 1];
			ArrayDeque<Integer> q = new ArrayDeque<>();
			vis[root] = true;
			q.add(root);
			while (!q.isEmpty()) {
				int cur = q.poll();
				if (mine.contains(cur)) {
					int ans = queryA(cur, fs);
					if (his.contains(ans)) {
						System.out.printf("C %d%n", cur);
						System.out.flush();
						continue cases;
					}
				}
				for (int i : adj[cur]) {
					if (!vis[i]) {
						q.add(i);
						vis[i] = true;
					}
				}
			}
			System.out.println("C " + -1);
			System.out.flush();

		}
	}

	static int queryA(int x, Scanner s) {
		System.out.printf("A %d%n", x);
		System.out.flush();
		int ret = s.nextInt();
		return ret;
	}

	static int queryB(int y, Scanner s) {
		System.out.printf("B %d%n", y);
		System.out.flush();
		int ret = s.nextInt();
		return ret;
	}

}
