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

public class ProblemD 
{
	static int n;
	static MyList[] graph;
	static boolean[] mine;
	static boolean[] liChan;
	
	public static void main(String[] args) 
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);
		
		int t = reader.nextInt();
		while (t > 0)
		{
			n = reader.nextInt();
			
			graph = new MyList[n];
			mine = new boolean[n];
			liChan = new boolean[n];
			
			for (int i=0; i<n; i++)
				graph[i] = new MyList();
			
			for (int i=1; i<n; i++)
			{
				int u = reader.nextInt()-1;
				int v = reader.nextInt()-1;
				
				graph[u].list.add(v);
				graph[v].list.add(u);			
			}
			
			int k1 = reader.nextInt();
			for (int i=0; i<k1; i++)
				mine[reader.nextInt()-1] = true;
			
			int k2 = reader.nextInt();
			for (int i=0; i<k2; i++)
				liChan[reader.nextInt()-1] = true;
			
			int last = -1;
			for (int i=0; i<n; i++)
				if (liChan[i])
					last = i;
			
			writer.println("B " + (last+1));
			writer.flush();
			
			int scan = reader.nextInt()-1;
			
			int got = makeBfs(scan);
			
			writer.println("A " + (got+1));
			writer.flush();
			
			scan = reader.nextInt()-1;
			
			if (liChan[scan])
				writer.println("C " + (got+1));
			else
				writer.println("C -1");
			
			writer.flush();
			t--;
		}
		
		writer.close();

	}
	
	static int makeBfs(int s)
	{
		Queue<Integer> queue = new LinkedList<Integer>();
		queue.add(s);
		
		boolean[] local = new boolean[n];
		local[s] = true;
		
		while (!queue.isEmpty())
		{
			int u = queue.remove();
			
			if (mine[u])
				return u;
			else
				for (int v : graph[u].list)
				{
					if (!local[v])
						queue.add(v);
					
					local[v] = true;
				}
		}
		
		return -1;
	}
	

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

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

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}	

}

class MyList
{
	ArrayList<Integer> list = new ArrayList<>();
}
