#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int dis[N], n;
vector<int> g[N], my, his;
void read(vector<int>& a) {
  int temp;
  a.clear();
  scanf("%d", &temp);
  for (int i = 0, b; i < temp; i++) {
    scanf("%d", &b);
    a.push_back(b);
  }
}
int ask(char c, int a) {
  cout << c << " " << a << endl;
  int ret;
  cin >> ret;
  return ret;
}
void dfs(int u, int p) {
  for (auto i : g[u])
    if (i != p) {
      dis[i] = dis[u] + 1;
      dfs(i, u);
    }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1, a, b; i < n; i++) {
      scanf("%d%d", &a, &b);
      g[a].push_back(b);
      g[b].push_back(a);
    }
    read(my);
    read(his);
    int y = ask('B', his[0]);
    dfs(y, -1);
    int at = my.front();
    for (auto i : my)
      if (dis[i] < dis[at]) at = i;
    y = ask('A', at);
    if (find(his.begin(), his.end(), y) != his.end())
      cout << "C " << at << endl;
    else
      cout << "C -1" << endl;
    for (int i = 0; i <= n; i++) g[i].clear();
  }
}
