#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long int;
using vi = vector<int>;
using namespace std;
ll if_found = -1;
void DFS(set<ll> &our, int v, vector<vector<int>> &gr, int pr) {
  if (our.find(v) != our.end()) {
    if_found = v;
    return;
  }
  for (int u : gr[v]) {
    if (u != pr) DFS(our, u, gr, v);
  }
}
int main() {
  ll n = 0, t = 0;
  cin >> t;
  for (int i = 0; i < t; i++) {
    ll n;
    if_found = -1;
    cin >> n;
    vector<vector<int>> gr(n);
    for (int i = 0; i < n - 1; i++) {
      ll u, v;
      cin >> u >> v;
      gr[u - 1].push_back(v - 1);
      gr[v - 1].push_back(u - 1);
    }
    ll k1;
    cin >> k1;
    set<ll> our;
    for (int i = 0; i < k1; i++) {
      ll v;
      cin >> v;
      our.insert(v - 1);
    }
    ll k2;
    cin >> k2;
    set<ll> lc;
    for (int i = 0; i < k2; i++) {
      ll v;
      cin >> v;
      lc.insert(v - 1);
    }
    cout << "B " << *lc.begin() + 1 << "\n";
    ll vert;
    cin >> vert;
    if (our.find(vert - 1) != our.end()) {
      cout << "C " << vert << "\n";
      cout.flush();
      continue;
    }
    DFS(our, vert - 1, gr, -1);
    cout << "A " << if_found + 1 << "\n";
    ll leec;
    cin >> leec;
    if (lc.find(leec - 1) != lc.end()) {
      cout << "C " << if_found + 1 << "\n";
      cout.flush();
      continue;
    } else {
      cout << "C " << -1 << "\n";
      cout.flush();
      continue;
    }
  }
}
