#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> x, y, adj[1001];
int k1, k2;
map<int, bool> mp, mp2;
int mn = 2001001001, ans = -1;
bool visited[1001];
void dfs(int node, int dis) {
  visited[node] = true;
  if (mp[node] && dis < mn) {
    mn = dis;
    ans = node;
  }
  for (int i : adj[node])
    if (!visited[i]) dfs(i, dis + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    cin >> N;
    for (int j = 0; j + 1 < N; j++) {
      int X, Y;
      cin >> X >> Y;
      adj[X].push_back(Y);
      adj[Y].push_back(X);
    }
    cin >> k1;
    for (int j = 0; j < k1; j++) {
      int temp;
      cin >> temp;
      mp[temp] = true;
    }
    cin >> k2;
    for (int j = 0; j < k2; j++) {
      int temp;
      cin >> temp;
      mp2[temp] = true;
      y.push_back(temp);
    }
    cout << "B " << y[0] << endl;
    cout << flush;
    int temp;
    cin >> temp;
    for (int j = 1; j <= N; j++) visited[j] = false;
    dfs(temp, 0);
    assert(ans != -1);
    cout << "A " << ans << endl;
    cout << flush;
    cin >> temp;
    if (mp2[temp])
      cout << "C " << ans << endl;
    else
      cout << "C " << -1 << endl;
    cout << flush;
    mp.clear();
    mp2.clear();
    mn = 2001001001;
    ans = -1;
    for (int j = 1; j <= N; j++) adj[j].clear();
    x.clear();
    y.clear();
  }
  return 0;
}
