#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1000 + 5;
long long n, u, v, k1, k2, tmp1, tmp2, fl;
vector<long long> adj[maxn];
vector<bool> p1(maxn, 0), p2(maxn, 0);
deque<long long> q;
void dfs(long long now, long long lst, long long gol) {
  if (fl or now == gol) {
    fl = 1;
    return;
  }
  for (auto x : adj[now]) {
    if (!fl and x != lst) {
      q.push_back(x);
      dfs(x, now, gol);
      if (!fl) q.pop_back();
    }
  }
}
void solve() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) p1[i] = p2[i] = 0, adj[i].clear();
  for (long long i = 0; i < n - 1; ++i) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  cin >> k1;
  for (long long i = 0; i < k1; ++i) cin >> tmp1, p1[tmp1] = 1;
  cin >> k2;
  for (long long i = 0; i < k2; ++i) cin >> tmp2, p2[tmp2] = 1;
  cout << "B " << tmp2 << "\n";
  cout << flush;
  cin >> tmp2;
  if (p1[tmp2]) {
    cout << "C " << tmp2 << "\n";
    cout << flush;
    return;
  }
  fl = 0, q.push_back(tmp1), dfs(tmp1, 0, tmp2);
  while (!q.empty()) {
    if (p1[q.front()]) tmp1 = q.front();
    q.pop_front();
  }
  cout << "A " << tmp1 << "\n";
  cout << flush;
  cin >> tmp2;
  if (p2[tmp2])
    cout << "C " << tmp1 << "\n";
  else
    cout << "C " << -1 << "\n";
  cout << flush;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
