#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
const long long inf = 1000 * 1000 * 1000 + 7;
const long long INF = inf * inf;
const long long MOD = inf;
const long long N = 1e3 + 10, base = 1 << 18;
vector<long long> G[N];
bool moje[N];
bool vis[N];
void solve() {
  long long n;
  cin >> n;
  for (long long i = (1); i <= (n); i++) {
    G[i].clear();
    moje[i] = false;
    vis[i] = false;
  }
  for (long long i = ((0)); i <= ((n - 1) - 1); i++) {
    long long a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  long long k1, k2;
  cin >> k1;
  for (long long i = ((0)); i <= ((k1)-1); i++) {
    long long a;
    cin >> a;
    moje[a] = 1;
  }
  cin >> k2;
  set<long long> jego;
  for (long long i = ((0)); i <= ((k2)-1); i++) {
    long long a;
    cin >> a;
    jego.insert(a);
  }
  cout << "B " << *jego.begin() << "\n";
  cout.flush();
  long long feed;
  cin >> feed;
  if (moje[feed]) {
    cout << "C " << feed << "\n";
    cout.flush();
    return;
  }
  queue<long long> q;
  q.push(feed);
  long long najblizsze;
  while (true) {
    long long x = q.front();
    q.pop();
    vis[x] = true;
    if (moje[x]) {
      najblizsze = x;
      break;
    }
    for (long long i : G[x])
      if (!vis[i]) q.push(i);
  }
  cout << "A " << najblizsze << "\n";
  cout.flush();
  cin >> feed;
  if (jego.find(feed) != jego.end())
    cout << "C " << najblizsze << "\n";
  else
    cout << "C -1\n";
  cout.flush();
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cout << setprecision(9) << fixed;
  cerr << setprecision(6) << fixed;
  long long test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
}
