#include <bits/stdc++.h>
using namespace std;
int n;
int size1;
int size2;
int myNodes[1000];
int liNodes[1000];
vector<int> graph[1000];
int makeQuery(char s, int n) {
  int v;
  printf("%c %d\n", s, n);
  fflush(stdout);
  scanf("%d", &v);
  if (v == -1) exit(0);
  return v;
}
int BFS(int p1) {
  pair<int, int> node1;
  set<int> visited;
  queue<pair<int, int> > toVisit;
  toVisit.push({p1, 1});
  visited.insert(p1);
  while (!toVisit.empty()) {
    node1 = toVisit.front();
    toVisit.pop();
    if (node1.second > size2) return -1;
    for (int node2 : graph[node1.first - 1]) {
      if (visited.insert(node2).second) {
        if (binary_search(myNodes, (myNodes + size1), node2)) return node2;
        toVisit.push({node2, node1.second + 1});
      }
    }
  }
  return -1;
}
int getCommonNode() {
  int v1;
  int v2;
  sort(myNodes, (myNodes + size1));
  sort(liNodes, (liNodes + size2));
  v1 = makeQuery('B', liNodes[0]);
  if (binary_search(myNodes, (myNodes + size1), v1)) return v1;
  v1 = BFS(v1);
  if (v1 == -1) return -1;
  v2 = makeQuery('A', v1);
  if (binary_search(liNodes, (liNodes + size2), v2)) return v1;
  return -1;
}
int main() {
  int t;
  int n;
  int v1;
  int v2;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &n);
    for (int j = 0; j < n; j++) graph[j].clear();
    for (int j = 0; j < (n - 1); j++) {
      scanf("%d", &v1);
      scanf("%d", &v2);
      graph[v1 - 1].push_back(v2);
      graph[v2 - 1].push_back(v1);
    }
    scanf("%d", &size1);
    for (int j = 0; j < size1; j++) scanf("%d", &myNodes[j]);
    scanf("%d", &size2);
    for (int j = 0; j < size2; j++) scanf("%d", &liNodes[j]);
    printf("C %d\n", getCommonNode());
    fflush(stdout);
  }
}
