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

public class IntersectingSubtrees {
	static InputReader f;
	public static void main(String[] args) throws IOException {
		InputStream is = System.in;
		f = new InputReader(is);
		int T = f.nextInt();
		for(int i = 0; i<T; i++) {
			solve();
		}
	}
	public static void solve() {
		int N = f.nextInt();
		node[] nodes = new node[N+1];
		for(int i = 1; i<=N;i ++)
			nodes[i] = new node();
		for(int i = 0; i<N-1; i++) {
			int a = f.nextInt();
			int b = f.nextInt();
			nodes[a].neighbor.add(b);
			nodes[b].neighbor.add(a);
		}
		int K = f.nextInt();
		HashSet<Integer> mytree = new HashSet<>();
		for(int i = 0; i<K; i++) {
			mytree.add(f.nextInt());
		}
		int L = f.nextInt();
		HashSet<Integer> litree = new HashSet<>();
		int check = -1;
		for(int i = 0; i<L; i++) {
			check = f.nextInt();
			litree.add(check);
		}
		System.out.println("B " + check);
		int start = f.nextInt();
		if(start == -1) {
			System.exit(0);
		}
		if(mytree.contains(start)) {
			System.out.println("C " + start);
		} else {
			int closest = dodijkstra(start, N, nodes, mytree);
			System.out.println("A " + closest);
			int his = f.nextInt();
			if(his == -1) {
				System.exit(0);
			}
			if(litree.contains(his)) {
				System.out.println("C " + closest);
			} else {
				System.out.println("C " + -1);
			}
		}
		System.out.flush();
	}
	public static int dodijkstra(int start, int N, node[] nodes, HashSet<Integer> mytree) {
		//dijkstra
		boolean[] visited = new boolean[N+1];
		ArrayDeque<Integer> queue = new ArrayDeque<>();
		queue.add(start);
		visited[start] =true;
		int closest = -1;
		while(queue.size() >0) {
			int n = queue.poll();
			for(int neighbor : nodes[n].neighbor) {
				if(!visited[neighbor]) {
					visited[neighbor] = true;
					if(mytree.contains(neighbor)) {
						closest = neighbor;
						return closest;
					}
					queue.add(neighbor);
				}
			}
		}
		return -1;
	}
	static class node {
		ArrayList<Integer> neighbor = new ArrayList<>();
		node() {
			
		}
	}
	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());
		}
	}
}
