#include <bits/stdc++.h>
using namespace std;
const long long N = 1005;
vector<long long> adj[N];
set<long long> a, b;
long long dist, node;
void dfs(long long u, long long pr, long long d) {
  if (a.count(u) && d < dist) dist = d, node = u;
  for (auto &v : adj[u])
    if (v != pr) dfs(v, u, d + 1);
}
void solve() {
  dist = 1e9;
  long long n;
  cin >> n;
  for (long long i = 0, u, v; i < n - 1; i++)
    cin >> u >> v, adj[u].push_back(v), adj[v].push_back(u);
  long long k1;
  cin >> k1;
  for (long long i = 0, x; i < k1; i++) cin >> x, a.insert(x);
  long long k2;
  cin >> k2;
  for (long long i = 0, x; i < k2; i++) cin >> x, b.insert(x);
  cout << "B " << (*b.begin()) << endl;
  long long val;
  cin >> val;
  dfs(val, val, 0);
  cout << "A " << node << endl;
  cin >> val;
  if (b.count(val))
    cout << "C " << node << endl;
  else
    cout << "C -1" << endl;
  a.clear(), b.clear();
  for (long long i = 0; i < N; i++) adj[i].clear();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) solve();
}
